Google Groups Home
Help | Sign in
Getting the quaternion of a single triangle in a trimesh
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
colmsloan@gmail.com  
View profile
 More options Mar 26, 12:53 am
From: "colmsl...@gmail.com" <colmsl...@gmail.com>
Date: Tue, 25 Mar 2008 21:53:00 -0700 (PDT)
Subject: Getting the quaternion of a single triangle in a trimesh
I need the quaternion of a triangle in the trimesh. When there's a
collision, I can use the index and the trimesh along with the get
triangle function to get the vertices of the triangle like so:
dVector3 v0, v1, v2;
dGeomTriMeshGetTriangle( trimeshGeom, triangleIndex, &v0, &v1, &v2 );

I'm actually not concerned with the imaginary 'w' component of the
quaternion so I'm only after the x, y and z. I thought I could get
these by getting the normal of the triangle:
D3DXVECTOR3 dxV1 ( v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2] );
D3DXVECTOR3 dxV2 ( v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2] );
D3DXVec3Cross( &triNormal, &dxV1, &dxV2 );

and then using that cross product of that and the inverse normal to
get the x, y and z components I desire, but it seems I'm very wrong.

Is there an easier way of doing this?

Thanks


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo Hernandez  
View profile
 More options Mar 26, 12:20 pm
From: Rodrigo Hernandez <kwiz...@aeongames.com>
Date: Wed, 26 Mar 2008 10:20:46 -0600
Local: Wed, Mar 26 2008 12:20 pm
Subject: Re: [ode-users] Getting the quaternion of a single triangle in a trimesh

This is the first time I ever hear of triangles inherently having
quaternions, so I don't know what you're talking about, however, I guess
that you could take the triangle normal, normalize one of the sides of
the triangle to get a perpendicular normal, get the cross product of
those to get a second "axis" and finally the cross product of the second
axis and the normal to get the third axis, stuff them in a 3x3 matrix (I
have no idea of the order though) and extract a quaternion from that.

This is of course all just thinking out loud.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo Hernandez  
View profile
 More options Mar 26, 12:25 pm
From: Rodrigo Hernandez <kwiz...@aeongames.com>
Date: Wed, 26 Mar 2008 10:25:47 -0600
Local: Wed, Mar 26 2008 12:25 pm
Subject: Re: [ode-users] Re: Getting the quaternion of a single triangle in a trimesh

PS: What I described is getting an orthonormal basis.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Watte  
View profile
 More options Mar 26, 2:05 pm
From: Jon Watte <jwa...@gmail.com>
Date: Wed, 26 Mar 2008 11:05:57 -0700
Local: Wed, Mar 26 2008 2:05 pm
Subject: Re: [ode-users] Getting the quaternion of a single triangle in a trimesh

colmsl...@gmail.com wrote:
> I need the quaternion of a triangle in the trimesh. When there's
> and then using that cross product of that and the inverse normal to
> get the x, y and z components I desire, but it seems I'm very wrong.

That's not a well-defined concept. You have to define what it is you
want better. A triangle does not, inherently, have a "rotation," any
more than it has a "translation." Those concepts can only be defined in
reference to some other state.

Also, normals don't have inverses, as they are vectors, not transforms.

Perhaps what you want is a rotation that takes the normal from the state
the triangle has in an untransformed mesh, and rotates the triangle to
match the new normal? The problem is that there is an infinity of such
rotations, because the triangle can be rotated any degree around the
normal. Perhaps what you want is the shortest circular rotation that
will make the identity normal align with the current triangle normal? Or
do you want the rotation that will make all vertices of the original
triangle align with the current triangle? In all these cases, the
assumed reference is an "untransformed" triangle, but if your triangle
mesh is static (doesn't move), then the rotation will always be identity.

So, if you can define what it is you want, then perhaps someone can help
you come up with how to get that. Or perhaps it falls out directly from
the definition.

Sincerely,

jw


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel K. O.  
View profile
 More options Mar 26, 2:58 pm
From: "Daniel K. O." <danielko.lis...@gmail.com>
Date: Wed, 26 Mar 2008 15:58:56 -0300
Local: Wed, Mar 26 2008 2:58 pm
Subject: Re: [ode-users] Getting the quaternion of a single triangle in a trimesh
colmsl...@gmail.com escreveu:

> I need the quaternion of a triangle in the trimesh.
[...]
> Is there an easier way of doing this?

To put what Rodrigo and John said in simpler terms:

What you said does not make much sense to us. Why don't you tell us what
you are trying to accomplish, so we can try to guide you to the
"easier"/correct solution?

Are you by any chance trying to convert between local/world coordinates?
The dGeomTriMeshGetTriangle() function returns the triangle in world
coordinates. To get local coordinates, just access the trimesh data you
provided to ODE instead of doing the inverse rotation+translation transform.

--
Daniel K. O.
"The only way to succeed is to build success yourself"


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
colmsloan@gmail.com  
View profile
 More options Mar 28, 3:37 pm
From: "colmsl...@gmail.com" <colmsl...@gmail.com>
Date: Fri, 28 Mar 2008 12:37:37 -0700 (PDT)
Local: Fri, Mar 28 2008 3:37 pm
Subject: Re: Getting the quaternion of a single triangle in a trimesh
Sorry about the late reply. Thanks for all of the feedback.

Apologies for poor explanation of what I want. I'll have another bash
at it. Here's a pic:
http://img510.imageshack.us/img510/7453/explanationce5.gif

how would I get the ray to change direction like this? I was using a
particular formula:
fluidCuboid-

>setNewWindDirection( fabs(dBodyGetQuaternion( dGeomGetBody( dSpaceGetGeom( _turbineSpace,

i )) )[1]),
fabs(dBodyGetQuaternion( dGeomGetBody( dSpaceGetGeom( _turbineSpace,
i )) )[2]),
fabs(dBodyGetQuaternion( dGeomGetBody( dSpaceGetGeom( _turbineSpace,
i )) )[3]) );

and this was working perfectly but now I've changed my setup so I no
longer have contact details (I was testing on a box but now I'm
testing on a trimesh). Any ideas?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
colmsloan@gmail.com  
View profile
 More options Mar 28, 3:42 pm
From: "colmsl...@gmail.com" <colmsl...@gmail.com>
Date: Fri, 28 Mar 2008 12:42:14 -0700 (PDT)
Local: Fri, Mar 28 2008 3:42 pm
Subject: Re: Getting the quaternion of a single triangle in a trimesh
Sorry, I forgot to mention that my trimesh isn't static.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gazi Alankus  
View profile
 More options Mar 28, 4:09 pm
From: "Gazi Alankus" <ala...@gmail.com>
Date: Fri, 28 Mar 2008 15:09:30 -0500
Local: Fri, Mar 28 2008 4:09 pm
Subject: Re: [ode-users] Re: Getting the quaternion of a single triangle in a trimesh
I think the confusion is that the orientation you are looking for
seems not to be unique and can rotate around the normal of the
triangle. Similarly, in step 2 in the image, it seems like the ray
could go to any direction that is parallel to the plane of the
triangle.

I'm just speculating, maybe you want the initial ray to have the
smallest possible angle with the bouncing ray that is constrained to
be in the plane of the triangle (and any direction would be fine if
the ray was exactly parallel to the normal). In this case you can find
the direction of the second ray by just projecting the initial ray to
the plane of the triangle. A simple way to do that is to first project
the ray on the normal and subtract that from the ray.

Hope that helps.

-Gazi

On 28/03/2008, colmsl...@gmail.com <colmsl...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo Hernandez  
View profile
 More options Mar 28, 4:27 pm
From: Rodrigo Hernandez <kwiz...@aeongames.com>
Date: Fri, 28 Mar 2008 14:27:15 -0600
Local: Fri, Mar 28 2008 4:27 pm
Subject: Re: [ode-users] Re: Getting the quaternion of a single triangle in a trimesh

You don't need to rotate anything, just project the ray on the triangle
plane, to do that, in ODE lingo:

dVector3 output, trinormal ray;
dCROSS(output,=,ray,trinormal);
dCROSS(output,=,trinormal,output);
dNormalize(output);

where trinormal is the triangle normal and ray is the ray's direction
(destination-origin if you have it in segment notation).
output will contain the normalized direction of the projected ray.

You may notice this is very similar to what I described before, getting
the orthonormal basis for the triangle.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google