I have a set of 2D points (defining a flat 2D 'connect the dots' shape). I want to calculate the 3D positions for these 2D points at a specific 3D position and rotation.
For example, say I have five 2D points forming the shape of a 2D hexagon. I want to place this hexagon shape at a specific location in my 3D world, at a specific rotation. I need to calculate new 3D coordinates for each of the 2D points.
If it matters, the 2D points will center around (0,0).
What magic formula do I need to do to accomplish this translation? Is there a built in method (in Unity) to do this?
Each point will be perpendicular to the rotation angle/direction, so will I need to calculate the cross product? Then somehow use this to remap each 2D point?
I should have paid more attention to this in school, all those years ago (I can't even remember if I actually learned this before!).
Any help will be appreciated. Thanks.
Here's some basic code to illustrate:
Vector3 position; // Where in 3D to place the 2D shape
Quaternion rotation; // What 3D rotation to apply to the 2D shape. Should be a Vector3?
Vector2[] shapeIn; // List of 2D points defining shape
Vector3[] shapeOut; // List of updated 3D points at its new position and rotation
shapeOut = new Vector3[shapeIn.Length];
for (int p=0; p<shapeIn.Length; p++) {
shapeOut[p] = MagicFormula(shapeIn[p]);
}