How to combine 2 angles in 3D space

May 2017
Hi folks,

I have a bit of a problem and I can't seem to picture it in my mind or think of a way to draw it to help me solve it.

I'm working in a editing/compositing piece of kit called Flame.

In a 3D environment there is a camera which acts as the point of view and a flat finite surface with an axis attached.

What I want to do is write an expression, which is like a formula or line of code, to turn the surface invisible when it rotated away from the camera.

Now when the surface is directly in front of the camera I have done this by considering the x and y axis separately.

So for x: Say the angle facing camera is 0. using a sine function I can get a +ve number from -90 to 90 and -ve otherwise.

I did the same for y. I reasoned that multiplying the 2 results would give a +ve or -ve flag for the transparency.

ie if you turned on the x axis 120 degrees (so away from camera) then the y 180 say, the 2 -ves would make a +ve and you'd see the surface.

Not sure how to denote this mathematically but it seems correct when I imagine it.

This works perfectly when I build it too.

I reasoned that z axis rotation makes no difference.

By the way the axis rotates round with the surface rather than staying locked in space

But then, when you start moving the surface in x and y it all falls apart and I can no longer picture the system.

I think what I need to do is work out the angle from the surface to the camera point.

So if you image holding a post-it (my surface) 50cm in front of your face so the angle of the surface to your eye is 90 degrees.

Now rotate the post-it on its x and y axis. So far so good.

But move the post-it a distance to your left and up a bit. Rotate in x and y.

Now, knowing all these values, how do you calculate the angle of the surface to your eye?

if -90<theta<90 then it's visable.

Otherwise it's transparent.

Any ideas?