[Closed] Face Normals Issue
obj = $Plane001 --if this is the plane, then
dot obj.dir (normalize (-obj.pos)) > 0 --this is true if facing the origin, false of not
The basic idea is this:
The .dir is the same as .transform.row3 which is the Z axis of the object.
Then you take the position of the object and subtract from [0,0,0], which is equivalent to the negative of the position.
You want to calculate the dot product of these two vectors, so you have to make sure the position one is normalized (dot product of non-normalized vectors makes no sense).
When the dot product is positive, the two vectors point in the same direction. When the dot product is 1.0, they are parallel. When the dot product is 0, the two are perpendicular. When the dot product is -1.0, they are parallel and pointing in opposite directions.
So you want to know when the dot product becomes positive to tell whether the vector connecting the position of the object and the origin is in the same 180 degrees hemisphere as the object’s Z axis.
Hope this helps.
Here is a surprise – I don’t know whether it can be done correctly. I suspect it cannot, but somebody might be able to hack something together… I would never attempt to do that myself, knowing how limited the scripted spline plugin implementation is.
We could, assuming we know what axes we can rotate about.
It is usually easier to simply align the Z axis to the vector connecting the position and the origin (assuming you want the plane to LOOK AT the 0,0,0 point).
So, the simplest script to do this would be
obj.dir = -obj.pos
Amazing, isn’t it?
Of course, if you want to preserve specific axes orientations, you could go farther by constructing a matrix out of 3 vectors while keeping the row4 at the current position.
In general, it is always easier to tell the object its final orientation (absolute) rather than figuring out the delta between the current orientation and the desired one and attempting to rotate it…
I have no idea what the plane is for. Can you explain WHY you need it and re-write your workflow list into WHAT you want to achieve instead of HOW you want to achieve it?
If I can understand the goal, I might understand the logic of what you are trying, too.
At the moment, it makes no sense to me. (a small sketch or drawing could be useful, too)