POV-Ray : Newsgroups : povray.advanced-users : Calculate distance between point and viewport Server Time: 30 Mar 2020 12:04:39 GMT
  Calculate distance between point and viewport (Message 1 to 4 of 4)  
From: Mike Horvath
Subject: Calculate distance between point and viewport
Date: 23 Feb 2020 18:01:04
Message: <5e52bde0$1@news.povray.org>
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);


Post a reply to this message

From: Bald Eagle
Subject: Re: Calculate distance between point and viewport
Date: 23 Feb 2020 18:50:00
Message: <web.5e52c861dd9dce8e4eec112d0@news.povray.org>
VDist(V1, V2). Compute the distance between two points.
Parameters:

V1, V2 = Input vectors.

http://www.povray.org/documentation/view/3.7.1/459/

So, you could either compute the distance between the Camera_Transform[ed]
Camera_Location and Camera_LookAt, or since IIRC the default camera uses a
projection plane one POV-unit away from the camera, you could normalize that and
multiply it by the length of the Camera_Distance vector...

Mike Horvath <mik### [at] gmailcom> wrote:
> 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.

Or you could use a Graphics Gems macro to actually calculate the shortest
(perpendicular) distance between the (transformed) camera point and the
(transformed) up-right plane.


Post a reply to this message

From: Mike Horvath
Subject: Re: Calculate distance between point and viewport
Date: 23 Feb 2020 19:55:01
Message: <5e52d895@news.povray.org>
On 2/23/2020 1:45 PM, Bald Eagle wrote:
> 
> VDist(V1, V2). Compute the distance between two points.
> Parameters:
> 
> V1, V2 = Input vectors.
> 
> http://www.povray.org/documentation/view/3.7.1/459/
> 
> So, you could either compute the distance between the Camera_Transform[ed]
> Camera_Location and Camera_LookAt, or since IIRC the default camera uses a
> projection plane one POV-unit away from the camera, you could normalize that and
> multiply it by the length of the Camera_Distance vector...
> 

No, the first point is somewhere in space and is not connected to the 
camera.



> Mike Horvath <mik### [at] gmailcom> wrote:
>> 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.
> 
> Or you could use a Graphics Gems macro to actually calculate the shortest
> (perpendicular) distance between the (transformed) camera point and the
> (transformed) up-right plane.
> 
> 

The plane doesn't actually have to be the up-right plane exactly, but it 
does need to be parallel to it and lie somewhere beyond the extents of 
the model.



Mike


Post a reply to this message

From: Bald Eagle
Subject: Re: Calculate distance between point and viewport
Date: 23 Feb 2020 21:25:00
Message: <web.5e52ed3ddd9dce8e4eec112d0@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:

> No, the first point is somewhere in space and is not connected to the
> camera.
>
>
>
> > Mike Horvath <mik### [at] gmailcom> wrote:
> >> 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.
> >
> > Or you could use a Graphics Gems macro to actually calculate the shortest
> > (perpendicular) distance between the (transformed) camera point and the
> > (transformed) up-right plane.
> >
> >
>
> The plane doesn't actually have to be the up-right plane exactly, but it
> does need to be parallel to it

OK - that's just the plane equation, IIRC: Ax+By+Cz-D = 0
Also in F. Lohmueller's analytical geometry include file (Insert Menu?)
and you just set the "offset" from the origin with D.
same as you'd do with plane {z, D}

Then you calculate the distance of the point from that plane.

http://news.povray.org/povray.binaries.images/message/%3Cweb.5880fc4d1652a4dcc437ac910%40news.povray.org%3E/#%3Cweb.588
0fc4d1652a4dcc437ac910%40news.povray.org%3E

> and lie somewhere beyond the extents of
> the model.


That's confusing, since usually the image projection plane is "in front of" all
the stuff - between the camera and the "model", not "beyond the extents" of it.

But I think the link gives you exactly what you need.


Post a reply to this message

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.