0
votes

I have a 3d plane defined by a normal and distance, is there a way to rotate the plane to face a given point in the 3d world? I can calculate the normal easily (targetPos-objectPos normalized), however I am not sure how the distance should be recalculated so the plane keeps the same "origin".

I am trying to build the plane to intersect an object in the 3d world and face the camera so I can perform ray casting on it.

1
What do you consider the plane's origin? - Nico Schertler
Right now I build a X and Z plane that intersect an object in the scene, however for the Y I need the plane to always face the camera and intersect the object as well. For example this is for the X plane: PLANE_X = new CC3Plane(new CC3Vector(0, 0, 1), selectedObject.z) - Anton Banchev
So you need the distance of the object along a given normal? That's dot(normal, objectPos). - Nico Schertler

1 Answers

0
votes

If I understand your post correctly the distance is how far the plane is away from the origin along the normal vector. This means that if you're trying to rotate the plane but keep the same origin then it's impossible since changing the normal will move the whole plane around the origin.

It might be best to define a plane as two vectors, a position vector(p) and a normal vector(n), this gives the vector equation of a plane: p.n=d where d is a scalar value.

This would allow you to change the direction of the plane easily, for example if you wanted the plane to point at a point, P1, then you can calculate the new normal, n2, by: n2 = normalised(P1 - p).