следующий фpагмент (2)  Usenet echoes (21:200/1)  COMP.GRAPHICS.ALGORITHMS 
Msg : 4 of 9
From : eyal@fir.canberra.edu.au 2:5030/144.99 11 Aug 94 23:49:00
To : All 13 Aug 94 01:47:18
Subj : (1) Re: Flight Simulator 3D Equations

In <32brtf$66n@acmez.gatech.edu> gt6681c@prism.gatech.edu (Michael Steven Heyda)
writes:
>I have the basic equations to do pitch,roll,and yaw translations
>on the object but those equations don't allow the ship to fly
>(respond to controls) correctly.
>E.g. when you pull back on the stick it should always pitch up
>relative to your perspective looking out the cockpit, not pitch
>up relative to the coordinate system.
>The pitch problem I figured out but I can't lay my finger on the
>solution to the yaw problem. i.e. when you yaw it should always
>go around in a circle, not just yaw on the coordinate system but
>relative to how you're looking out the cockpit.
>Does anyone have some flight sim source they could share or just
>point me the right direction.
The trick here is to do the rotation in the correct order, then it works
as you expect. The common order is to rotate in this order:
yaw
pitch
roll
Now, this will take you from fixed (world) coords to body coords which
are then used for the display. However, if you want to update the
attitude based on the controls then you will start with the body
attitude matrix and apply the above rotation. If you want now to go back
to world coords then you simply use the inverse (in this case the
transpose is the same) matrix.
If your body is rotating at the time and has inertia then you will want
to use a 6dof set of rules instead; these can be used in full, or in a
simplified form where you ignore some of the precession effects.
Another simple approach is to convert the WORLD Euler angles (heading, pitch
roll) with the BODY angular rates (yawrate, pitchrate, rollrate)
into WORLD angular rates (headingrate, pitchrate, rollrate) and then
simply add these to the world Euler angles (heading, pitch, roll). These
formulaes are simple and will work fine as long as you keep the rotation
small, which means the frame rate high enough, or you simulate each
frame in multiple small steps.
All angles/rates in radians.
We start with knowing:
worldpitch [known]
worldyaw (heading) [known]
worldroll [known]
bodypitchrate [from controls]
bodyyawrate [from controls]
bodyrollrate [from controls]
We end up with
worldpitchrate
worldyawrate
worldrollrate
which we add back to the world angles.
The calcs are (note that the order IS important):
worldpitchrate = rollrate * cos(roll)  yawrate * sin(roll)
worldyawrate = yawrate * cos(roll)  pitchrate * sin(roll)
worldrollrate = rollrate  worldyawrate * sin(pitch)
Now you add woldpitchrate to worldpitch etc. Do note that this last
'add' is really 'integrate' and how complex you make it depends on how
much fidelity you need.
Hpoe this clarifies the situation a bit.

Regards
Eyal Lebedinsky eyal@ise.canberra.edu.au
следующий фpагмент (3)пpедыдущий фpагмент (1)
 Usenet echoes (21:200/1)  COMP.GRAPHICS.ALGORITHMS 
Msg : 117 of 165
From : UUCP 2:5030/144.99 08 Sep 94 16:50:22
To : All 11 Sep 94 05:36:58
Subj : (1) Re: Movement in 3d space?

Dear Terry,
as far as I see it, you should use the following transformations:
Let vp(x,y,z) be the view point in world coordinates.
Let vp(x^,y^,z^) be the view point in viewing coordinates.
Let vp(x¦,y¦,z¦) be the new view point in world coordinates.
Apply first the xrotation (pitch), then yrot. (yaw) and finally
zrot. (roll).
The transformation matrices are:
 1 0 0 
Rx =  0 cos(pitch) sin(pitch) 
 0 sin(pitch) cos(pitch) 
 cos(yaw) 0 sin(yaw) 
Ry =  0 1 0 
 sin(yaw) 0 cos(yaw) 
 cos(roll) sin(roll) 0 
Rz = sin(roll) cos(roll) 0 
 0 0 1 
The transformation is:
vp(x^,y^,z^) = vp(x,y,z)*Rx*Ry*Rz
After this transformation, apply the movement delta to the z^ coordinate
of your view point (right handed coordinate system), since you have
the viewing coordinates as follows: x^ and y^axis from bottom left
to bottom right and top left corners of your screen. z^ point
right into your eyes, hence:
a negative delta to get closer, a positive delta to get away
Then apply a reverse transformation.
This is easy, since the transformation matrices are orthogonal. Thus,
inverse of B equals transposed of B (== transp. B)
vp(x¦,y¦,z¦) = vp(x^,y^,z¦+delta)*(transp. Rz)*(transp. Ry)*(transp. Rx)
Hope this is correct, since it's a long time ago that I dealed with that stuff.
A tip: the book Fundamentals of Interactive Graphics by Foley/van Dam
is very helpful. (AddisonWesley Systems Programming Series)
Sincerely,
следующий фpагмент (4)пpедыдущий фpагмент (2)
 Usenet echoes (21:200/1)  COMP.GRAPHICS.ALGORITHMS 
Msg : 127 of 163
From : c2a192@ugrad.cs.ubc.ca 2:5030/144.99 08 Sep 94 19:36:36
To : All 11 Sep 94 05:37:04
Subj : (1) Yaw, Pitch and Roll...

A while ago someone was asking how to perform yaw, pitch and roll
relative to virtual airplane's coordinate system, so that pulling back
on the stick will make the plane go up with respect to the cockpit,
not the ground.
I recently rewritten my transformation module to allow just that sort
of thing, and more.
A camera is represented by three orthonormal basis vectors, call them
u, v, w. The observer looks "through" vector w. Vector v points up,
relative to the cockpit. Vector v points to the right. As you can see,
I use a righthanded coordinate systems, with objects receding into
the negativez distance.
Now, the three camera basis vectors can be combined to form the
columns of an orhogonal matrix Q. (orthogonal matrix = columns are
mutually perpendicular, and are all unit length).
You can apply a transformation, such as a rotation, to this matrix
using straight multiplication, as in:
Qnew = TQ
where T is the transformation matrix.
This method works relative to absolute coordinates, not relative to
the camera coordinates.
It turns out that if you want the transformation to affect the camera
relative ot it's own coordinates, all you have to do is reverse the
multiplication:
Qnew = QT
What this does now is project the transformation T into the column
space of the camera Q.
For instance, if T is a transformation that represents a pitchup of
15 degrees, the transformation
TQ
Will rotate camera Q by 15 degrees around the X axis. However, the
transformation
QT
will rotate the camera about vector v (the one that points left). In
other words, it will perform the pitch operation relative to the
camera's position.
When you have your camera defined this way, the way you apply the
camera to the scene is: for each point x in the scene, do
T T
x_new = Q x where Q is the transpose matrix of Q.
Because Q is an orthogonal matrix, its inverse is simply the
transpose, so no computing is required to get the inverse.
The following is a formula for transforming a point relative to the
camera's coordinates, rather than absolute coordinates:
T
x_new = Q T Q x_old
The point x_old is first multiplied by the inverse of Q to convert it
to a coordinate system that is relative to the camera. Once it is in
this coordinate system, it is multipled by T to perform the
transformation. Then, it is multiplied by Q to bring it back to
absolute coordinates. In this way, we represent a complex
transformation by decoupling it into a change of coordinates and a
simpler transformation.
Notice that to transform the camera itself about its own coordinates,
the formula reduces as follows:
T
Q_new = QTQ Q
T
= QTI (Q Q = identity matrix)
Q_new = QT
which is just the formula given previously.
Всего 3 фpагмент(а/ов) пpедыдущий фpагмент (3)
