- Home /
Obtain plane equation from eulerAngles
Hi everyone. I have a plane in the scene that the player can rotate. Based on the plane's euler angles, is there an easy way for me to calculate the coefficients a, b, c, and d of the plane's equation ax+by+cz+d=0?
Thanks!
Not based solely on the euler angles - you need a point on the plane (e.g. it's position).
Oh okay. If I have the position and rotation values, how would I go about calculating the coefficients? Thank you!
Not really a Unity question. To get to a Cartesian equation you might want to start with a point and a normal. The point will be the 'transform.position' of the plane. Assu$$anonymous$$g you are talking about a Unity plane object, the normal will be the 'transform.up' of the plane. Then:
http://www.wikihow.com/Find-the-Cartesian-Equation-of-a-Plane
Answer by whydoidoit · Feb 13, 2014 at 05:34 PM
It's calculated from a point and a vector like this (presuming it's a Unity transform of a Unity Plane);
a = transform.up.x;
b = transform.up.y;
c = transform.up.z;
d = -Vector3.Dot(transform.up, transform.position);
If you want to calculate it from an angle and a point then:
var normal = Quaternion.Euler(yourAngle) * Vector3.up; //Presu$$anonymous$$g the plane faces upwards
a = normal.x; //etcetera