So what is it. I have a specific Point3D. I have a camera. I know the camera angle, which is 45 degrees; I know the position of the camera and the LookDirection vector. Now I want to find out if the dot will be visible to the camera or not.
Thanks for those who answered and commented, but:
This is not an easy problem for me. This may seem like a simple thing, but I did not find a special method or helper class to solve the problem. I tried to solve it myself in a purely mathematical way, but the solution is unstable and works unpredictably:
bool isPointInCameraView(Point3D P, Point3D CP, Vector3D LD, double CameraAngle) { //first calculate Distance to the plane formed by normal vector LD and point P on it var D = -LD.X*PX-LD.Y*PY-LD.Z*PZ; // -AXb-BYb-CZb //L is the distance to the plane. double L = Math.Abs( (LD.X * CP.X + LD.Y * CP.Y + LD.Z * CP.Z + D)) / Math.Sqrt(LD.X * LD.X + LD.Y * LD.Y+LD.Z * LD.Z); var BL = L * Math.Tan(CameraAngle); //length of bound part var PL = Math.Sqrt(((new Vector3D(PX - CP.X, PY - CP.Y, PZ - CP.Z)).LengthSquared - L * L)); // length of point part //test if point is out of bounds! return PL <= BL; }
I know about Helix3D, and I use it. My viewport and camera are from the helix framework.
I think it will be easier to understand the problem if I explain the reason why I need such a test. I am creating a geophysical data visualization application, and I need to be able to bring the depth closer to the texture in order to see the details. The problem was that I could not use textures that were too large, since they took up too much memory and took too long to draw. Then I decided to divide my plane into several touch-ups, each of which should be handled separately. So the idea is that when the user approaches a certain part of the plane, I would only do this part. It worked fine, except that the code was still redrawing textures for those subpriklings that were invisible to the camera. Now I want to optimize this. I tried to find any special function that would allow me to do this, but failed. So while the solution is only mathematical and unstable, it does not work correctly. That is why I asked this question here.
source share