So that's it. I have a certain Point3D. I have a camera. I know the view angle of the camera, which is 45 degrees; I know camera position and LookDirection vector. Now I want some way to find out whether the point will be visible to the camera or not.
Thanks for those who have answered and commented, but:
This is not a straightforward problem for me. This may seem a simple thing, but I didn't find any special method or helper class to solve the problem. I have tried solving it myself, in a purely math way, but the solution is unstable and works unpredictable:
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*P.X-LD.Y*P.Y-LD.Z*P.Z; // -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(P.X - CP.X, P.Y - CP.Y, P.Z - CP.Z)).LengthSquared - L * L)); // length of point part //test if point is out of bounds! return PL <= BL; }
I do know about Helix3D and I am using it. My Viewport and Camera are from helix framework.
I think that it will be easier to understand the problem if I explain the reason why I need this kind of test. I am building a geoscience visualisation application, and I need to be able to zoom deep into the texture to see details. The problem was that I couldn't use too large textures, as they would take up too much memory, and take too long to draw. I decided then to divide my plane into several subrectangles, each of which should be handled separatedly. So the idea is that when the user zooms into certain part of the plane, I would render that part only. It worked ok, except the code still repainted textures for those subrectangles that were invisible to the camera. Now I want to optimize this. I tried searching for any special function that would let me do it, but no success. So for now the solution is only mathematical and it's unstable, it's working wrong. That's why I asked this question here.