Page 1 of 1

how to calculate radius points of camera positions x y z ?

Posted: Wed Apr 07, 2010 7:20 am
by gpu-renderer
Hi all

Does anyone know how to caculate the radius of the camera from the center point in octane. I am trying to figure out a fixed horizonel orbit path divided by 16 positions (images) around an object.

Not sure if you can snap to center view with octane.

(I wish the x,y,z was in degrees make life so much easier) and a point to center of object option for the camera.

Also a round up to 1.X/1.xx/1.xxx decimel or by exact degree.

Any suggestions or tools to work this out would be welcomed.

Re: how to calculate radius points of camera positions x y z ?

Posted: Wed Apr 07, 2010 5:05 pm
by radiance
you have to project them onto a sphere.

leave the look at to the origin, eg 0, 0, 0.
then project your theta and phi onto a sphere.
first you convert your degrees to radians for theta and phi (theta is angle up/down and phi the rotation horizontally),
then map them to a sphere with trigonometry, and the distance from the origin is the scale:

x = scale * sin(theta) * cos(phi);
y = scale * sin(theta) * sin(phi);
z = scale * cos(theta);


Radiance

Re: how to calculate radius points of camera positions x y z ?

Posted: Wed Apr 07, 2010 5:58 pm
by vagos21
If i understood well what you wanna do here, it's a geometry problem ;)
A spherical to cartesian coordinate conversion is what you need, which you can calculate (if i remember well) with these formulas:

x - x0 = r * sin(θ) * cos(φ)
y - y0 = r * sin(θ) * sin(φ)
z - z0 = r * cos(θ)

http://upload.wikimedia.org/wikipedia/c ... m_SZ_0.svg

where
x,y,z = camera position you're looking for,
x0, y0, z0 = target position (i suggest you take these coords from your modelling app, not easy to track in octane)
r = distance between target and camera - calculated via formula r = sqrt[ (x-x0)^2 + (y-y0)^2 + (z-z0)^2 ]

watch out! angles theta (θ) and phi (φ) are calculated in radians, not degrees! you have to convert that too :D -thank god i'm greek and can easily type these characters! So in your case, you want to take shots of a constant r and θ, and a φ changing from 0 to 360 degrees, divided by 16 positions, so your φ step is 360/16= 22.5 degrees. which in rads is --> rad = degree*π/180 so your φ step is 22.5*3.14159/180= 0.3927 rads!!

suppose your camera is at (3,2,5) and your target at (2,0,4) :
r = sqrt[ (3-2)^2 + (2-0)^2 + (5-4)^2 ] = sqrt[1+4+1] = 2.4495 meters
and constant θ can be automatically calculated through these distances too according to this formula:
θ = atan[ (z-z0) / sqrt[(x-x0)^2+(y-y0)^2] ] = atan[ 1 / sqrt(1+4) ] = atan[1/2.2361 * π/180] = 0.0078 rads

so finally all you have to do is....

[position n in your fly-around path]
x = x0 + r * sin(θ) * cos(φ) = 2 + 2.4495 * sin(0.0078) * cos(n*0.3927)
y = y0 + r * sin(θ) * sin(φ) = 0 + 2.4495 * sin(0.0078) * sin(n*0.3927)
z = z0 + r * cos(θ) = 4 + 2.4495 * cos(0.0078)

replacing n with 0 to 16, you'll get all your 16 camera positions....



looking back at all this... what a mess!!! that's why quaternions were invented
good luck!

Edit: I think i was typing this at the same time with radiance. just took a bit longer to explain hehe :ugeek:

Re: how to calculate radius points of camera positions x y z ?

Posted: Wed Apr 07, 2010 8:29 pm
by BroAugustine
Hi,

For those not into trigonometry, I've added a little tutorial in the Resources and Sharing forum for visually matching camera positions in Blender and Octane. It should work with other modeling packages too. See http://www.refractivesoftware.com/forum ... =21&t=1040