How to calculate if a point in a cube is visibility in WPF 3D

I want to show the Perspective cube, so I have to calculate if a point in the cube is visibility.

Like the image, the red top should be invisible and the rest should be visible.

Can anyone give me a formula to calculate?

The cube can be rotated to prevent me from doing this.

I am trying to use HitTest for this, but it has poor performance.

I want to know the formula for calculating the visibility of a point and face and line.

Edit:

Point is any point on a line.

I am creating it using Media3D.

+3


source to share


2 answers


If any of the faces associated with a vertex have a normal facing the camera (see the reverse side of the drop), the vertex is visible. This should be pretty quick to calculate.



+1


source


Try taking the point product of the "camera vector" (usually (0,0,1)) and all the normal vectors of the cube collide with the vertex in question.
If any of the dot products return a negative value, then the angle between the camera vector and the normal vector of the corresponding surface of the cube is greater than 90 degrees and therefore "facing" the camera.
If the point of interest is a vertex, you will use three point products. If the point of interest is along the line between the vertices, you will only calculate two.



+1


source







All Articles