- Home /
Question by
username707 · Jul 19, 2013 at 07:47 AM ·
rotationarraytranslateorientationmatrix
How to rotatate an array of points(x,z) around origin point(x,z)?
I have a array of (x, z) points, representing positions on a plane. I need to translate and rotate theese points around point of origin according to its position and rotation.
Comment
Best Answer
Answer by username707 · Jul 19, 2013 at 11:19 AM
float angle = squadLeader.transform.rotation.eulerAngles.y * Mathf.PI/180;
float originX = squadLeader.transform.position.x; float originZ = squadLeader.transform.position.z;
float dxPos = Mathf.Sin(angle) (originX- xPos) - Mathf.Cos(angle) (zPos- originZ) + originX; float dzPos = Mathf.Cos(angle) (originX- xPos) + Mathf.Sin(angle) (zPos- originZ) + originZ;
or
Quaternion q = Quaternion.AngleAxis(Vector3.up * 90f);
point = q * (point-origin) + origin;
Your answer
![](https://koobas.hobune.stream/wayback/20220613110424im_/https://answers.unity.com/themes/thub/images/avi.jpg)