Home Products Download Order Contacts


Subject: Re: 3D camera question

> Really stuck here, and could use some help. I'm trying to add a camera to my
> 3D engine. Say I just have one shape - a large triangle that's acting as the
> ground plane.
> The triangle is not transformed, as you can see the arguments to the
> rotation and translation are 0. For reference, I have one of the matrix
> methods below, it sets it up and then multiplies. If I change the values of
> my camera rotation, the triangle still rotates as if I were simply rotating
> it (from its center) and not the camera. I know I need to subtract the
> location of the camera relative to the shape, but Im not sure how/where to
> do this. Can anyone help? Please let me know if you need more information.

Let the camera be defined by a homogeneous matrix 4*4 C, such that the 3
first vectors represent the x, y and z axes of the camera (with the
homogeneous w = 0) and the last vector represents the position of the
camera (point, thus with w = 1).

Given any point, the matrix C represent a transformation from camera
space to the world space. Now I must assume column vectors are used, but
this should not be an issue. Thus:

Cx = y

x is a point in camera space
y is a point in world space

If the camera axes x,y,z are linearly independent, then C is invertible

x = (C^-1)y

The result:
To transform a point in world space to the camera space you need to
transform it with the *inverse* of the camera matrix.

If you are unfamiliar with homogeneous stuff:
An affine transformation can be given in the form
f(x) = Ax + b

A contains the camera axes
b is the camera position

The inverse of the transformation, if exists (A nonsingular), is:
f^-1(x) = (A^-1)(x - b)

Using the same reasoning as before then:
x = f^-1(y) = (A^-1)(y - b)

Kalle Rutanen


View All Messages in comp.graphics.algorithms

3D camera question =>

Re: 3D camera question

Copyright 2006 WatermarkFactory.com. All Rights Reserved.