POV-Ray : Newsgroups : povray.general : defying perspective : Re: defying perspective Server Time
4 Aug 2024 22:12:26 EDT (-0400)
  Re: defying perspective  
From: Charles
Date: 30 Jan 2003 20:01:59
Message: <3E39CC27.31786399@enter.net>
James Taylor wrote:
> 
> Ok, so here's an example of whta I'm trying to achieve.
> Take two small(ish) spheres A and B. Place A near to the camera and B a fair
> distance from the camera. Both A and B are at the same height above a ground
> plane, but due to perspective B will appear lower on the screen than A. How
> do I figure how much to vertically translate B by such that it appears at
> the same height on the screen as A? (scale is not an issue in this scene)
> 
> hoping that all made sense.
> thanks
> jim

#declare CamLoc=<someviewpoint>; /*pre-declare your camera's location
                                  so you can play with it below...*/
#declare ObjLoc1=<someplace>;
#declare ObjLoc2=<someplaceelse>;
#declare DiffScale=vlength(ObjLoc1-CamLoc)/vlength(ObjLoc2-CamLoc);
#declare DiffFactor=(1-DiffScale)*Loc2;

Having declared these ahead, the transform you want for Object 2 
(assuming you want Object 2 to look the same size as Object 1) 
is...

 matrix<
     DiffScale, 0, 0,
     0, DiffScale, 0,
     0, 0, DiffScale,
     DiffFactor.x, DiffFactor.y, DiffFactor.z
   >


This will, of course, not work well with large objects or short
distances
because the objects are not, naturally, at a single point in space and
you'll still get some perspective distortion, but for some cases, it
might
achieve more or less what you're trying for.

Just in case matrices make you gasp like being dunked in cold water,
all this does is takes a ratio of the distances between the objects,
translates object 2 to the origin, scales it according to the ratio,
then translates it back again. (The matrix is just a more compact way
of doing it all in one move, hence saving you 0.001 seconds of parsing
time). :) 

-- 
@C[$F];
The Silver Tome ::  http://www.silvertome.com 
"You may sing to my cat if you like..."


Post a reply to this message

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