- Home /
This question was
closed Mar 14, 2020 at 05:29 AM by
Existingman for the following reason:
Other
Question by
Existingman · Mar 14, 2020 at 01:16 AM ·
rotationmeshvector3geometry
Use Unity's transform API to manipulate points?
I want to proceduraly generate meshes. I created a method to supply the vertices of a circle. The idea is that it creates a shape in 2d and then rotates it in 3d assuming that "rotation" is the vector of the shapes normal axis.
public List<Vector3> Loop (Vector3 center, Vector3 rotation, float radius, int divisions)
{
List<Vector3> loop = new List<Vector3>();
for(int p = 0; p < divisions; p++)
{
float u = (float)Math.Cos(2 * Math.PI * p / divisions) * radius;
float v = (float)Math.Sin(2 * Math.PI * p / divisions) * radius;
float x = 0;
float y = 0;
float z = 0;
// Apply rotation to u & v to get x, y, z
loop.Add(new Vector3(x, y, z));
}
return loop;
}
Creating the circle in 2d (u & v) was super easy but when I looked into applying 3d rotations, it seemed to be a complete rabbit hole completely beyond my comprehension.
Is there a way to use existing API to do this?
Comment
Follow this Question
Related Questions
Rotating direction vectors 1 Answer
How to achieve a rotation on "batch quads" ? 0 Answers
How to rotate Vector3 to EulerAngle? 1 Answer
Get Direction from 2 Vectors - and Apply to Transform 0 Answers
Rotating wrong 0 Answers