mocapsim - Motion Capture Simulator & Editor

back to tabinda© | mocapsim on sourceforge | download mocapsim
subglobal1 link | subglobal1 link | subglobal1 link | subglobal1 link | subglobal1 link | subglobal1 link | subglobal1 link
subglobal2 link | subglobal2 link | subglobal2 link | subglobal2 link | subglobal2 link | subglobal2 link | subglobal2 link
subglobal3 link | subglobal3 link | subglobal3 link | subglobal3 link | subglobal3 link | subglobal3 link | subglobal3 link
subglobal4 link | subglobal4 link | subglobal4 link | subglobal4 link | subglobal4 link | subglobal4 link | subglobal4 link
subglobal5 link | subglobal5 link | subglobal5 link | subglobal5 link | subglobal5 link | subglobal5 link | subglobal5 link
subglobal6 link | subglobal6 link | subglobal6 link | subglobal6 link | subglobal6 link | subglobal6 link | subglobal6 link
subglobal7 link | subglobal7 link | subglobal7 link | subglobal7 link | subglobal7 link | subglobal7 link | subglobal7 link
subglobal8 link | subglobal8 link | subglobal8 link | subglobal8 link | subglobal8 link | subglobal8 link | subglobal8 link

software

The Software 

The Software Part of this Project is in itself a total 3D Motion Capture Simulation Editor and Viewer. To better understand the working of the software, there are certain things that need to be explained before the actual design.

3D Transformation and its Theory

2D and 3D vector geometry

2D and 3D geometry is quite fundamental to the model based approach to computer vision and even when algorithms are not specifically model based they are still often a compact way to construct and implement an algorithm.

3D Viewing Projections

Introduction

The basic problem is to map a 3D object to a 2D Display surface.

Two General Methods :

 

  • Parallel Projection
  • Perspective Projection

 


Parallel Viewing Projections

Projection rays (projectors) emanate from a Center of Projection (COP) and intersect Projection Plane (PP). The COP for parallel projectors is at infinity. The length of a line on the projection plane is the same as the "true Length".

 

There are two different types of parallel projections:

If the direction of projection is perpendicular to the projection plane then it is an orthographic projection. If the direction of projection is not perpendicular to the projection plane then it is an oblique projection.

 

Look at the parallel projection of a point (x, y, z). (Note the left handed coordinate system). The projection plane is at z = 0. x, y are the orthographic projection values and xp, yp are the oblique projection values (at angle a with the projection plane)

Look at orthographic projection: it is simple, just discard the z coordinates. Engineering drawings frequently use front, side, top orthographic views of an object.

Here are three orthographic views of an object.

 

Orthographic projections that show more than 1 side of an object are called axonometric orthographic projections. The most common axonometric projection is an isometric projection where the projection plane intersects each coordinate axis in the model coordinate system at an equal distance.

 

Isometric Projection

 

The projection plane intersects the x, y, z axes at equal distances and the projection plane Normal makes an equal angle with the three axes.

To form an orthographic projection xp = x, yp= y , zp = 0. To form different types e.g., Isometric, just manipulate object with 3D transformations.

 

Oblique Projection

 

The projectors are not perpendicular to the projection plane but are parallel from the object to the projection plane The projectors are defined by two angles A and d where:


A = angle of line (x,y,xp,yp) with projection plane,

 

d = angle of line (x, y, xp, yp) with x axis in projection plane

 

 

L = Length of Line (x,y,xp,yp).

Then:
cos d = (xp - x) / L ------> xp = x + Lcos d ,

sin d = (yp - y) / L ------> yp = y + Lsin d ,

tan A = z / L

Now define L1 = L / z ----> L= L1 z ,

so tan A = z / L = 1 / L1 ; xp = x + z(L1cos d) ; yp = y + z(L1sin d)

| 1 0 0 0 |

P = | 0 1 0 0 |

| L1cosq L1sinq 1 0 |

| 0 0 0 1 |

Now if A = 90° (projection line is perpendicular to PP) then tan A = infinity => L1 = 0, so have an orthographic projection.

Two special cases of oblique projection

A) A = 45° , tan A = 1 => L1 = 1 This is a Cavalier projection such that all lines perpendicular to the projection plane are projected with no change in length.

 

B) tan A = 2, A= 63.40°, L1 = 1 / 2
Lines which are perpendicular to the projection plane are projected at 1 / 2 length . This is a Cabinet projection.


 


Perspective Viewing Projection

The Perspective viewing projection has a Center of Projection ("eye") at a finite distance from the projection plane (PP).

So the distance of a line from the projection plane determines its size on the projection plane, i.e. the farther the line is from the projection plane, the smaller its image on the projection plane. In the two images above, the projections of L1 = L2 but the actual length of L1 <> L2. Perspective projection is more realistic since distant objects appear smaller.

 



Computing the Perspective Projection

 

Look at above diagram from y axis

Now x / (z+d) = xp / d
xp = x[d / (z+d)]
xp = x / (z / d + 1)

 

 

Do same for y (look down the x axis) and get


y p = y / (z / d+1)
zp = 0

Note that we can increase the perspective effect by decreasing d (moving closer). We can represent this in matrix form by using homogeneous coordinates as follows:

 

[xh yh zh w]=[x y z 1]

|1 0 0 0 |

|0 1 0 0 |

|0 0 0 1/d |

|0 0 0 1 |

where:
xh = x

yh= y

zh = 0

w = (z/d) + 1

And Points on the projection plane are [xp yp zp 1] = [xh/w yh/w zh/w 1]
This leads to the same xp, yp as before.

A problem with a perspective transformation is that it does not preserve straight lines or planes, i.e., straight lines are not transformed into straight lines and planes are no longer planar after the transformation.

Look at example of a 3D line in object space from:

P1 (x1 = 2.0, y1 = 5.0, z1 = 6.0) to P2 (x2 = 8.0, y2 = 7.0, z2 = 12.0)

In parametric form this line is represented as:

x(t) = 2 + 6 × t

y(t) = 5 + 2 × t

z(t) = 6 + 6 × t

Let us choose an arbitrary value of t (t = 0.4) and compute the x, y, z values)

x = 2 + 2 × 0.4 = 4.4

y = 5 + 2 × 0.4 = 5.8 so Pi(t = 0.4) = (4.4, 5.8, 8.4)

z = 6 + 6 × 0.4 = 8.4

Now perform the perspective transformation (assume d = 10.0) for P1, Pi, P2. Then we get for the transformed points:

P1(x = 1.25, y = 3.125, z = 6); Pi(x = 2.39, y = 3.15, z = 8.4);

P2(x = 3.64, y = 3.18, z = 12)

If this is still a straight line then all three coordinates of point Pi must have the same value of the parameter t.

so for x we get 2.39 = 1.25 + t × (2.39) =>t = 0.48

for y we get 3.15 = 3.12 + t × (0.57) => t = 0.48

for z we get t = 0.40 since unchanged => therefore the points are not collinear.

To maintain linearity we can do a perspective depth transformation:

Zp = Z / (D + Z)

Then for point 1 Zp = 6 / (10+6) = .375

point 2 Zp = 12 / (10+12) = .545

point i Zp = 8.4 / (10+8.4) = .457

Now check with t value for point i 0.457 = 0.375 + t * (0.170) = .48. This is the same t value we got for point i x and y. Therefore points 1, 2, and i are still collinear after the perspective depth transformation.. Note that the relative z depth values remain unchanged, i.e. if Z1 < Z2 then Z1 / (Z1+d) < Z2 / (Z2+d) as shown below:

Z1 < Z2

Z1 × d < Z2 × d multiply both sides by d

(Z1 × Z2 + Z1 × d) < (Z1 × Z2 + Z2 × d) add Z1 × Z2 to both sides

Z1 × (Z2 + d) < Z2 × (Z1 + d)

Z1 / (Z1 + d) < Z2 / (Z2 + d)

Note that for Zp = Z / (Z+d) => 0 if d >> Z and => 1.0 if Z >> d

Therefore 0.0 <= Zp <= 1.0

So to maintain linearity (or planarity) we must transform Z as well as X and Y.

Vanishing Points

Any set of parallel lines that are not parallel to the projection plane will converge to a vanishing point. If the set of lines is parallel to one of the three principal axis then it is called a principal vanishing point.

In this image the X and Y lines are parallel to the Z axis. Since the projection plane is normal to the Z axis there is only one principal vanishing point. Lines parallel to either X or Y axis are parallel to projection plane and have no vanishing point. So it is a one-point projection.

1ptpersp.gif (20863 bytes)

In this image the lines are not parallel to the z axis. Since the projection plane is normal to the z axis there is only one principal vanishing point. Lines parallel to either x or y axis are parallel to projection plane and have no vanishing point. So it is a one-point projection.

2ptpersp.gif (21837 bytes)

Quaternion & Euler Concepts

Overview

The quaternion number system was discovered by Hamilton, a physicist who was looking for an extension of the complex number system to use in geometric optics. Quaternions have developed a wide-spread use in computer graphics and robotics research because they can be used to control rotations in three dimensional space. In these notes we define and review the basic properties of quaternions.

What are Quaternions?

Remember complex numbers? These numbers are an extension of the real number system and can be written in the form a + bi , where a and b are both real numbers and i 2 = - 1 . The quaternions are just an extension of this complex number form.

A quaternion is usually written as

q = a + b i + c j + d k 

where a , b , and c are scalar values, and i , j and k are the unique quaternions with the properties that

i 2 = - 1 , j 2 = - 1 , k 2 = - 1

and

ij = k ,

jk = i ,

ki = j

ji = - k ,

kj = - i ,

ik = - j

This is clearly an extension of the complex number system – where the complex numbers are those quaternions that have c = d = 0 and the real numbers are those that have b = c = d = 0 .

Adding and Multiplying Quaternions

Addition of quaternions is very straightforward: We just add the coefficients. That is, if q 1 = a 1 + b 1 i + c 1 j + d 1 k and q 2 = a 2 + b 2 i + c 2 j + d 2 k , then the sum of the two quaternions is

q 1 + q 2 = ( a 1 + a 2 ) + ( b 1 + b 2 ) i + ( c 1 + c 2 ) j + ( d 1 + d 2 ) k

Multiplication is somewhat more complicated, as we must first multiply componentwise, and then use the product formulas for i , j , and k to simplify the resulting expression. So the product of q 1 and q 2 is

q 1 q 2 = ( a 1 + b 1 i + c 1 j + d 1 k ) ( a 2 + b 2 i + c 2 j + d 2 k )

= a 1 a 2 + a 1 b 2 i + a 1 c 2 j + a 1 d 2 k + b 1 a 2 i + b 1 b 2 ii + b 1 c 2 ij + b 1 d 2 ik

+ c 1 a 2 j + c 1 b 2 ji + c 1 c 2 jj + c 1 d 2 jk + d 1 a 2 k + d 1 b 2 ki + d 1 c 2 kj + d 1 d 2 kk

= ( a 1 a 2 - b 1 b 2 - c 1 c 2 - d 1 d 2 ) + ( a 1 b 2 + a 2 b 1 + c 1 d 2 - d 1 c 2 ) i

+ ( a 1 c 2 + a 2 c 1 + d 1 b 2 - b 1 d 2 ) j + ( a 1 d 2 + a 2 d 1 + b 1 c 2 - c 1 b 2 ) k

An Alternate Representation for Quaternions

The expression for multiplication of quaternions, given above, is quite complex – and results in even worse complexity for the division and inverse formulas. The quaternions can be written in an different form 2 – one which involves vectors – which dramatically simplifies the formulas. These expressions have become the preferred form for representing quaternions.

In this form, the quaternion q = a + b i + c j + d k is written as

( a, ~v )

where ~v is the vector < b, c, d > .

We can rewrite the addition formula for two quaternions q 1 = ( a 1 , ~v 1 ) and q 2 = ( a 2 , ~v 2 ) as

q 1 + q 2 = ( a 1 + a 2 , ~v 1 + ~v 2 )

and the product formula as

q 1 q 2 = ( a 1 a 2 - ~v 1 · ~v 2 , a 1 ~v 2 + a 2 ~v 1 + ~v 1 × ~v 2 )

With some algebraic manipulation, these formulas can be shown to be identical with those of the i , j , k representation. We note that the quaternions of the form ( a,< 0 , 0 , 0 > ) can be associated with the real numbers, and the quaternions of the form ( a,< b, 0 , 0 > ) can be associated with the complex numbers.

Properties of Quaternions

With this new representation, it is straightforward to develop a complete set of properties of quaternions.

Given the quaternions q = ( a, ~v ) , q 1 = ( a 1 , ~v 1 ) , and q 2 = ( a 2 , ~v 2 ) , we can verify the following properties.

• Addition – The sum of q 1 and q 2 is

q1 + q2 = (a1 + a2, ~v1 +~v2) 

• Negation – The additive inverse - q of q is a

-q = (-a,-~v) 3

• Subtraction – The difference of q 1 and q 2 is

q1 - q2 = q1 + (-q2) = (a1 - a2, ~v1 -~v2) 

• Multiplication – The product of q 1 and q 2 is

q1q2 = (a1a2 -~v1 · ~v2, a1~v2 + a2~v1 +~v1 ×~v2)

• Identity – The multiplicative identity is (1 ,~ 0) . This can be directly checked by

(a, ~v)(1,~0) = (a -~v · ~0, a~0 + 1~v +~v ×~0) = (a, ~v)

(1,~0)(a, ~v) = (a -~0 · ~v, 1~v + a~0 +~0 ×~v) = (a, ~v)

• Multiplicative Inverse – The inverse q - 1 of q = ( a, ~v ) is given by

q-1 = _ a

a2 + |~v|2 , -~v

a2 + |~v|2_

This can be checked easily once we calculate that

( a, ~v )( a, - ~v ) = ( a 2 + ~v · ~v, - a~v + a~v + ~v × ( - ~v ))

= a 2 + | ~v | 2

and so qq - 1 = q - 1 q = (1 ,~ 0) .

• Division – The quotient of q 1 and q 2 is

q 1

q 2

= q 1 q - 12

Notation

Quaternions of the form ( a,~ 0) are normally denoted in their real number form – as a . this allows a scalar

multiplication property to be given by 4

• Scalar Multiplication – If c is a scalar, then

c q = ( c,~ 0) q

= (c,~0)(a, ~v)

= (ca -~0 · ~v, c~v + a~0 +~0 ×~v)

= (ca, c~v)

It also allows us to simplify some expressions. For example, the expression for the multiplicative inverse can now be written

 

• Multiplicative Inverse – The inverse q - 1 of q = ( a, ~v ) is given by

q-1 =

(a,-~v) a 2 + | ~v | 2

 

This also allows us to write the multiplicative identity of the quaternions as 1 instead of (1 ,~ 0) , and the additive identity as 0 .

The Quaternions are not Commutative under Multiplication

Whereas we can add, subtract, multiply and divide quaternions, we must always be aware of the order in which these operations are made. This is because quaternions do not commute under multiplication – in general q 1 q 2 6 = q 2 q 1 .

To give an example of this consider the two quaternions q 1 = (1 ,< 1 , 0 , 0 > ) and q 2 = (2 ,< 0 , 1 , 0 > ) . Multiplying these we obtain

q 1 q 2 = (2 - 0 ,< 0 , 1 , 0 > +2 < 1 , 0 , 0 > + < 0 , 0 , 1 > ) = (2 ,< 2 , 1 , 1 > )

or

q 2 q 1 = (2 - 0 , 2 < 1 , 0 , 0 > + < 0 , 1 , 0 > + < 0 , 0 , - 1 > ) = (2 ,< 2 , 1 , - 1 > )

and they are not equal. This is because the vector cross products give different results depending on the order of the vectors – in general, ~v 1 × ~v 2 6 = ~v 2 × ~v 1 .5

Length of a Quaternion, Unit Quaternions

We define the length of a quaternion q = ( a, ~v ) to be

| q | = p a 2 + | ~v | 2

where | ~v | is the length of the vector ~v . The unit quaternions are those that have length one.

About | Copyright | Contact Me | © 2006-2008 M.H.A.Q.S.