- Home /
How can I calculate the area of projection while using a projector component?
I need to simulate a projector on a platform in order to project an image on a wall and I am using the projector component for the same. I have the coordinates for the centre of the projection and have set the FOV and aspect ratio to the required values. Now I need to determine the exact area of the obtained projection for some testing and validation purposes. Is there any simple or direct way to get this from the projector component?
I also tried detecting the 4 corner points of the projection by rotating the ray drawn from the projector location to the centre of projection. As I understand, simultaneous rotation would be required around 2 axes in order to rotate a ray to face a corner of the projection. I haven't worked much with graphics or unity before, but I tried to rotate the ray using the following code:
Quaternion rotationBR = Quaternion.AngleAxis (horizontalFOV / 2f, transform.up) * Quaternion.AngleAxis (FOV / 2f, transform.right);
Vector3 BR = rotationBR * projectionCentreDirection;
Ray ray1BR = new Ray(destination, BR);
Vector3 pointBR = destination; //TO CHANGE
if (Physics.Raycast (ray1BR, out hit, 100f, layerMask)) {
pointBR = hit.point;
}
The corner point obtained using the above code was very slightly off the corner of the actual projection. I think that might be due to the rotations taking place one after the other. Could someone kindly explain how I could correct the slight error in the coordinates of the corner point? Any help would be greatly appreciated.
Thanks and regards JT
Your answer
![](https://koobas.hobune.stream/wayback/20220612090532im_/https://answers.unity.com/themes/thub/images/avi.jpg)