POV-Ray : Newsgroups : povray.advanced-users : Find exact position of a rotated camera Server Time
23 Nov 2024 23:12:23 EST (-0500)
  Find exact position of a rotated camera (Message 1 to 3 of 3)  
From: CVADRAT
Subject: Find exact position of a rotated camera
Date: 5 Jan 2011 07:00:01
Message: <web.4d245c4e38cab2dfcaf4e69e0@news.povray.org>
Hi all!

I need to find the exact position of a translated and rotated camera. Imagine a
sphere and a camera that points to it (with look_at to <0,0,0>, the center of
the sphere) with camera location at <0,0,-15000> and that then has been rotated
by +60 degrees in the x axis. What I need to find is the location vector of the
camera.
In fact I need the location vector of the camera to make a trace() on the


Any ideas will be welcome.

Please try to send me an email.

Thanks in advance!
CVADRAT


Post a reply to this message

From: Roman Reiner
Subject: Re: Find exact position of a rotated camera
Date: 5 Jan 2011 08:00:00
Message: <web.4d246a3c780a807ec9c2a02e0@news.povray.org>
vrotate() should do the trick:

vrotate(A,B)
Rotate A about origin by B. Given the x,y,z coordinates of a point in space
designated by the vector A, rotate that point about the origin by an amount
specified by the vector B. Rotate it about the x-axis by an angle specified in
degrees by the float value B.x. Similarly B.y and B.z specify the amount to
rotate in degrees about the y-axis and z-axis. The result is a vector containing
the new x,y,z coordinates of the point.

In your example, the new location can be found by calling vrotate(<0,0,-15000>,
<60,0,0>).

Regards Roman


"CVADRAT" <lud### [at] cvadratcom> wrote:
> Hi all!
>
> I need to find the exact position of a translated and rotated camera. Imagine a
> sphere and a camera that points to it (with look_at to <0,0,0>, the center of
> the sphere) with camera location at <0,0,-15000> and that then has been rotated
> by +60 degrees in the x axis. What I need to find is the location vector of the
> camera.
> In fact I need the location vector of the camera to make a trace() on the

>
> Any ideas will be welcome.
>
> Please try to send me an email.
>
> Thanks in advance!
> CVADRAT


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Find exact position of a rotated camera
Date: 20 Feb 2011 16:40:00
Message: <web.4d618925780a807ec734aecd0@news.povray.org>
"CVADRAT" <lud### [at] cvadratcom> wrote:
> Hi all!
>
> I need to find the exact position of a translated and rotated camera. Imagine a
> sphere and a camera that points to it (with look_at to <0,0,0>, the center of
> the sphere) with camera location at <0,0,-15000> and that then has been rotated
> by +60 degrees in the x axis. What I need to find is the location vector of the
> camera.
> In fact I need the location vector of the camera to make a trace() on the

>
> Any ideas will be welcome.
>
> Please try to send me an email.
>
> Thanks in advance!
> CVADRAT


You might want to try the code below.

Tor Olav
http://subcube.com


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#include "colors.inc"
#include "transforms.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Sphere =
  sphere {
    <0, 0, 0>, 500
    pigment { color White }
  }

#declare pCameraLocation = <0, 0, -1500>;
#declare pCameraLookAt = <0, 0, 0>;

#declare Camera =
  camera {
    location pCameraLocation
    look_at pCameraLookAt
  }

// This should work as long as there is no uneven scaling
#declare CameraTransform =
  transform {
//    translate 400*y
    rotate 60*x
  }

#declare NewCamera =
  camera {
    Camera
    transform { CameraTransform }
  }

#declare pNewCameraLocation =
  vtransform(
    pCameraLocation,
    CameraTransform
  );

#declare pNewCameraLookAt =
  vtransform(
    pCameraLookAt,
    CameraTransform
  );

#declare vNewCameraDirection =
  pNewCameraLookAt - pNewCameraLocation;

#declare vNormal = <0, 0, 0>;

#declare pIntersection =
  trace(
    Sphere,
    pNewCameraLocation,
    vNewCameraDirection,
    vNormal
  );

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Blue/2 }

light_source { <100, 2000, -1000>, color White }

object { Sphere }

#if (vlength(vNormal) > 0)
  sphere {
    pIntersection, 10
    pigment { color Orange }
  }
#else
  #debug "\n"
  #debug "No intersection"
  #debug "\n"
#end // if

camera {
//  Camera
  NewCamera
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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