POV-Ray : Newsgroups : povray.general : perspective user defined camera? : Re: perspective user defined camera? Server Time
30 Apr 2024 21:08:27 EDT (-0400)
  Re: perspective user defined camera?  
From: Tor Olav Kristensen
Date: 31 Jan 2019 20:35:01
Message: <web.5c53995562f292194c4249d90@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>
> > No problem. It was an interesting problem to solve.
> >
> > You don't have to deal much with matrices to do this. (I just showed the
> > relationship in case anyone is interested.)
>
> This is only tangentially related:
>
> Would something related to this be the preferred way to set up a scene so that
> an object would occupy a specific position on the screen - back calculating to
> determine where the camera should be?
>
> So, let's say there are 2 views (I think that might be necessary to get Z), each
> showing the same cube (and maybe a reference point like the origin) from a
> different vantage point.
> I'm presuming that a matrix would be the best way to reverse-project back to
> where the camera should be?
>
> It's just something that struck me with the functions, and matrices, and
> user-define camera...

I'm not sure if I understand what you mean.

In order to bring an object to a certain position on the screen, the camera can
be anywhere in space before rotating it towards the object.

To do that you translate the camera to origo, rotate it around an axis - or
reorient it from one vector to another (which is the same as rotating around an
axis) and then you translate it back to where it "came from".

If everything stays in 3 dimensions (i.e. using vectors with 3 components and
3x3 matrices) then the rotation (or reorientation) can be done with a matrix
multiplication, but the translations can not.

If you convert the 3D vectors into 4D vectors (by using homogeneous coordinates)
and use 4x4 matrices, then translations can also be done with matrix
multiplications (which, BTW, is why POV-Ray's matrices have 4 rows). All the
matrices (for translation, rotation/reorientation and back translation) can be
multiplied with each other to create one final matrix that "does it all".
Multiplying the camera vectors by this matrix will now bring the object into the
given screen position.

--
Tor Olav
http://subcube.com


Post a reply to this message

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