POV-Ray : Newsgroups : povray.advanced-users : Calculate distance between point and viewport : Calculate distance between point and viewport Server Time19 May 2024 12:50:45 EDT (-0400)
 Calculate distance between point and viewport
 From: Mike Horvath Date: 23 Feb 2020 13:01:04 Message: <5e52bde0\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#5e52bde0%241%40news.povray.org",
"headline": "Calculate distance between point and viewport",
"dateCreated": "2020-02-23T18:01:04+00:00",
"datePublished": "2020-02-23T18:01:04+00:00",
"author": {
"@type": "Person",
"name": "Mike Horvath"
}
}
How do I calculate the distance between a point and the camera? Except,
I am using an orthographic camera, so I really need the distance between
a point and the plane formed by the camera's up and right vectors.
Here's my camera definition. Thanks.

Mike

#declare Camera_Diagonal	= cosd(45);
#declare Camera_Aspect		= image_height / image_width;
#declare Camera_Width		= 10240;	// was 7680 * 4/3
#declare Camera_Vertical	= 225;		// was 225
#declare Camera_Horizontal	= 30;
#declare Camera_Distance	= Camera_Width;
#declare Camera_Up			= -y * Camera_Diagonal * Camera_Width * Camera_Aspect;
#declare Camera_Right		= +x * Camera_Diagonal * Camera_Width;
#declare Camera_Location	= -z * Camera_Distance;
#declare Camera_Direction	= +z * Camera_Distance;
#declare Camera_LookAt		= Camera_Location + Camera_Direction;
#declare Camera_Rotate		= <-Camera_Horizontal,Camera_Vertical,0,>;
#declare Camera_Scale		= 4;
#declare Camera_Translate	= <0,0,0>;
#declare Camera_Transform = transform
{
rotate		Camera_Rotate
scale		Camera_Scale
translate	Camera_Translate
}

camera
{
orthographic
up			Camera_Up
right		Camera_Right
location	Camera_Location
direction	Camera_Direction
transform {Camera_Transform}
}

#declare Camera_Location	= vtransform(Camera_Location,Camera_Transform);
#declare Camera_LookAt		= vtransform(Camera_LookAt,Camera_Transform);
```