Problems to constrain 3d rotations

graphics

    Next

  • 1. Hypertextures
    Hello. I've got few questions about hypertextures. 1. What is the diffrence between hypertexture and volume textures? 2. Where hypertextures can be used? 3. Is there any movie where hypertextures was used? f.e. "Monsters inc"? Thanks for quick answer. I need it badly. :) -- Klan
  • 2. cellnoise in c++??
    RenderMan Shading language has a noise function called "cellnoise()". Does anybody know what this is expressed in C++? Thank you in advance!! Best Sam
  • 3. Text rotation along all axis
    Hi, I am looking to add text rotation to my application. Ideally i would rotate over the X, Y and Z axis, would there be a C++ function out there that can handle those rotations? I cannot find any code to rotate the text, can anybody help me? ( I found the code below but it does not work at all and i do not know what the size of the text will be). void DrawRotatedText(HDC hdc, char *str, LPRECT rect, double angle, UINT nOptions = 0) { // convert angle to radian double pi = 3.141592654; double radian = pi * 2 / 360 * angle; // get the center of a not-rotated text SIZE TextSize;; GetTextExtentPoint32(hdc, str, strlen(str), &TextSize); POINT center; center.x = TextSize.cx / 2; center.y = TextSize.cy / 2; // now calculate the center of the rotated text POINT rcenter; rcenter.x = long(cos(radian) * center.x - sin(radian) * center.y); rcenter.y = long(sin(radian) * center.x + cos(radian) * center.y); // finally draw the text and move it to the center of the rectangle SetTextAlign(hdc, TA_BASELINE); SetBkMode(hdc, TRANSPARENT); ExtTextOut(hdc, rect->left + (rect->right - rect->left) / 2 - rcenter.x, rect->top + (rect->bottom - rect->top) / 2 + rcenter.y, nOptions, rect, str, strlen(str), NULL); } Many thanks Sims

Problems to constrain 3d rotations

Postby newsreader » Wed, 11 Aug 2010 00:48:17 GMT

Hello,

apologies if this is a well known topic or covered in the faq,
however, I could not find any information that did help me.

Ok, to start off I want to constrain rotations in 3d space.
While it is fairly trivial for one axis to give rotation limits
and to fix rotations around the other two axes to be zero, I do
have the problem that I cannot define constraints on two axes
and leave only the third one fixed to zero.

How does this reflect? Well, imagine I have a camera fixed at
some position. What I want to do is to follow an object through
space (without moving but only re-orienting the camera). Now,
what I did so far is simply taking the vector from my eye-point
to the object (V), take the cross product between this and the view-
direction (D), hence got a general rotation axis (A=VxD) and used
this and the arcus cosinus of the dot product between V and D as
angle to define the complete rotation. (Assume I did all the
normalization stuff etc.) When I apply this rotation, the view-
vector is perfectly pointing at the object.
So far everything is fine. If now the object is moving in a
circular pattern (lets say it circles on a plane perpendicular
to the original viewing direction around the point defined by
the intersection of said plane and the original "line of sight")
the camera starts to rotate around this vector. If the object is
rotating ccw also the cam starts to rotate ccw and vice versa. The
effect is larger when the circle diamteter get larger and smaller
if it is closely around the original view direction. First I
assumed this as a bug, but I'm pretty sure that the code is correct.

Can you tell or hint me how to prevent the cam from doing these
unintuitive movements? It might be of interest that my original input
is an axis/angle rotation (might be I could recover the original object
position, but this might become pretty tough). I can transform the
axis/angle into quaternions and/or matrices, however, tests showed
that using quaternions in a naive way (i.e. simply transformimg the
data) does not result in any better behaviour.

I appreciate ANY help on that topic, i.e. not only a solution, but
also pointers to respective articles, possible workarounds, etc. are
highly welcome!

Best regards,
  -- NR

Re: Problems to constrain 3d rotations

Postby RM » Wed, 11 Aug 2010 05:08:01 GMT



The camera starts to roll / z-rotate ?


After you rebuild your transformation recompute your "left" vector
from the new "forward" vector (that points to the target) and the "up"
vector from your old transformation using cross product. Then
recompute your "up" vector from these new left/forward vectors in the
same way. This will keep your "left" vector horizontal, preventing the
z-rotation.

Regards,

Richard Maudsley

Re: Problems to constrain 3d rotations

Postby Tommy Hinks » Thu, 02 Sep 2010 18:36:18 GMT



You might check out the classic ArcBall paper by Shoemake from -92
(possibly his other papers as well). It describes a nice approach to
interactive rotations and also deals with the type of constraints you
are looking for. The solutions presented in this paper are very
elegant and I would guess that they are widely used.

T

Similar Threads:

1.Problems to constrain 3d rotations

Hello,

apologies if this is a well known topic or covered in the faq,
however, I could not find any information that did help me.

Ok, to start off I want to constrain rotations in 3d space.
While it is fairly trivial for one axis to give rotation limits
and to fix rotations around the other two axes to be zero, I do
have the problem that I cannot define constraints on two axes
and leave only the third one fixed to zero.

How does this reflect? Well, imagine I have a camera fixed at
some position. What I want to do is to follow an object through
space (without moving but only re-orienting the camera). Now,
what I did so far is simply taking the vector from my eye-point
to the object (V), take the cross product between this and the view-
direction (D), hence got a general rotation axis (A=VxD) and used
this and the arcus cosinus of the dot product between V and D as
angle to define the complete rotation. (Assume I did all the
normalization stuff etc.) When I apply this rotation, the view-
vector is perfectly pointing at the object.
So far everything is fine. If now the object is moving in a
circular pattern (lets say it circles on a plane perpendicular
to the original viewing direction around the point defined by
the intersection of said plane and the original "line of sight")
the camera starts to rotate around this vector. If the object is
rotating ccw also the cam starts to rotate ccw and vice versa. The
effect is larger when the circle diamteter get larger and smaller
if it is closely around the original view direction. First I
assumed this as a bug, but I'm pretty sure that the code is correct.

Can you tell or hint me how to prevent the cam from doing these
unintuitive movements? It might be of interest that my original input
is an axis/angle rotation (might be I could recover the original object
position, but this might become pretty tough). I can transform the
axis/angle into quaternions and/or matrices, however, tests showed
that using quaternions in a naive way (i.e. simply transformimg the
data) does not result in any better behaviour.

I appreciate ANY help on that topic, i.e. not only a solution, but
also pointers to respective articles, possible workarounds, etc. are
highly welcome!

Best regards,
  -- NR

2.constrain rotation about axis?

3.Constrained quaternion rotation

Hi All,

I have a quaternion representing the 3D rotation of a model. During
interactive 3D rotation I wuold like to constrain the Z axis to lay on
the YZ plane.

Does an easy way exists? I already tryed to reset the x/y/z/w values
of the rotation but didn't help.

Thanks!

Alberto

4.from not-constrained to constrained traingulation

Hi,
i have a working 2D triangulation (not constrained).
building a  "constrained"  triangulation starting from it is possible?
or the algorithm is too much different?

Thanx

Davide


5.constrained 3D delaunay triangolation

Hi to all,
i am not a "math adept"..
however i need to use costrained delaunay trinagolation..
can some one point me to a good (ie easy to understand) note on that kind of
triangolation? so i can write the bits of  code i need?

Thanks to all

Davide


6. 3d sphere additive rotation back to lat/lon

7. 3D rotation matrix

8. 3D rotation about an arbitrary axis



Return to graphics

 

Who is online

Users browsing this forum: No registered users and 38 guest