I have a region with 3 normals and now I want to align a plane in this region. The two shown in the picture and one perpendicular facing up (created with pca, but that doesent matter)
GameObject Gplane = GameObject.CreatePrimitive(PrimitiveType.Plane);
Transform t = Gplane.transform;
t.position = segment.middle;
t.localScale = new Vector3((2*segment.dist_pc1)/10, 0, (2*segment.dist_pc2)/10);
t.rotation = Quaternion.FromToRotation(Vector3.right, segment.middle - segment.pc1);
t.rotation *= Quaternion.FromToRotation(Vector3.forward, segment.middle - segment.pc2);
t.rotation *= Quaternion.FromToRotation(Vector3.up, segment.normal)
I create a newgameobject from primitivetype plane. get transform and set its position and scale (segment is a object which contains all information about this region).
Then I want to align the plane with the three normal, each rotation works fine and aligns the plane with the axis, but multiplied its messed up.
As you can see the plane is kind of between the two normals (blue and red, which you can hardly see but i am sure you can image)
Any advice in what i am doing wrong is appreciated since i am not too familiar with quaternions and rotations.
Thanks in advance.