How to get cube face visibility relative to a point?

I have a cube, with rotation quaternion.identity,

lets say the cube is sitting at position (2,0,2). I then have point A at position (2,0,-2), and point B at position (17,0,-2).

My goal is to determine to which degree a given face of the cube is visible from a point, 2 of these possible points are points A and B. From point A the front face of the cube is directly alligned with point A, so there should be a variable that indicates that the front face is dead center visible from point A, and no other faces are visible. On the other hand, from point B the situation is different, both the front face and the left face of the cube are visible, but to different degrees of visibility.

What is the best method to create this evaluation?

After this, how can I then account for the cube to have a different rotation than quaternion.indentity, and have the world rotation of the cube taken into account for the calculations?

My endgoal is to get the (relative angle of the cube)/(amount of each face visible) from a given vector 3 position.

Here is an image to try to express what im trying to detect:

here from point A, I expect that only the front face of the cube (red) to be fully visible, and be the only visible face, while from point b, both the front and left(blue) face of the cube should be visible, to different degrees of visibility.

Thanks in advance

Im sure mathematically you can determine this. so, again assuming cube as described, you can tell point in relative from the center of the cube, so using human angles. If at 0,0,0 you are looking down on the cube, if any are 180 you are somewhere directly under the cube…

Probably just a case for using Dot product: Unity - Scripting API: Vector3.Dot

With respect to a the camera’s forward direction, and a direction leaving perpendicular to each face, you should get a result of less than zero if it’s facing towards the camera, and greater than zero if it’s facing away from the camera.

If you only care about comparing to a cube, I would just put an empty on each face with it’s forward direction facing outwards.

1 Like

hmmm well, truly i think what really matters to me is the rotation of the cube relative to the point that is observing the cube.

I only made it a cube because its easy to observe the state of the rotation by looking at the model by placing the camera at the desired point, to debug if the code was behaving as it should, but I was now trying to translate it to numbers.

What I mean I guess is that if the cube was so small that the faces were almost in the same position in theory I would expect the same results as if the cube was gigantic and the distance between each face was large