POV-Ray : Newsgroups : povray.advanced-users : Find exact position of a rotated camera : Re: Find exact position of a rotated camera Server Time
28 Sep 2024 06:08:43 EDT (-0400)
  Re: Find exact position of a rotated camera  
From: Tor Olav Kristensen
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.