I have a script attached to an object, and I am creating a plane as such:
bisector = new Plane(transform.forward, transform.position);
I eventually pass this to a function that needs to get the point used to create the plane for calculations. I attempt to get this point via the following:
Vector3 point = bisector.normal * bisector.distance;
When I do this though, I am getting a point in the opposite direction; it’s as if I multiplied by negative normal.
What am I doing wrong? I am ultimately trying to derive the point I passed as the second argument to the Plane constructor.
The API doc states that the constructor creates a plane that has a normal pointing to your transform.forward
direction and contains the transform.position
. So if this object is at (100,100,1) and facing toward the positive z-axis, your code would create a plane that contains every 3D point with the z-value of 1 in it. And
Vector3 point = bisector.normal * bisector.distance;
should result in point (0,0,1) because your plane’s shortest distance from (0,0,0) is 1 and the normal is also (0,0,1).
You can’t calculate the original point from the plane because it only has getters for the distance from (0,0,0) and the normal.
I guess you could extend the Plane class and make the subclass store the original point if you really need it.
EDIT:
Actually the bisector.distance
has a sign indicating whether you have to travel in the same direction as the normal (positive) or the opposite direction (negative) to reach (0,0,0). So my above example results in (0, 0, -1)