Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

Understanding Rotation Methods
Vote this thread:


@mega_p2k

Posts: 1

NGLNewbie

Fri, Jul 18 2014


Hi there,
the question of this thread has two parts: I first tell you what I want to do, so you can shoot your "No, you are doing it wrong" right away if you like. The other part is just for understanding and demonstration where I want to know why I get those results.

I want to copy the rotation of MeshA to MeshB which are on different NGLViews displayed side by side as some sort of comparison.

My approach is to get the final rotation matrix of MeshA and apply it to MeshB, because the rotation is performed by using rotateRelativeToX:toY:toZ: and thus, I'm not getting any values for rotationX/Y/Z (I know why, no need to explain that part).

Let's see the code:

// Rotate MeshA by 90° on its Z axis for demonstration
[MeshA rotateRelativeToX:0.0 toY:0.0 toZ:90.0];

// We get a pretty common rotation matrix for that
nglMatrixDescribe(*MeshA.matrix);
/*
Describe matrix:
|0.000026 -1.000000 0.000000 0.000000|
|1.000000 0.000026 0.000000 0.000000|
|0.000000 0.000000 1.000000 0.000000|
|0.000000 0.000000 0.000000 1.000000|
*/

// Just for demonstration, proof of the above with a quaternion
NGLQuaternion *quat = [[NGLQuaternion alloc] init];
[quat rotateByAxis:nglVec3Make(0.0, 0.0, 1.0) angle:90.0 mode:NGLAddModeSet];
nglMatrixDescribe(*quat.matrix);
/*
Describe matrix:
|0.000026 -1.000000 0.000000 0.000000|
|1.000000 0.000026 0.000000 0.000000|
|0.000000 0.000000 1.000000 0.000000|
|0.000000 0.000000 0.000000 1.000000|
*/
// NB: We can see that NinevehGL internally uses a quaternion

// Rotate MeshB with the rotation matrix of MeshA
[MeshB rotateWithMatrix:*MeshA.matrix];
nglMatrixDescribe(*MeshB.matrix);
/*
Describe matrix:
|1.000000 0.000000 0.000000 0.000000|
|0.000000 1.000000 0.000000 0.000000|
|0.000000 0.000000 1.000000 89.999985|
|0.000000 0.000000 0.000000 1.000000|
*/
// Sorry, what???

// Let's try to use the quaternion from before for demonstration
[MeshB rotateWithQuaternion:quat];
nglMatrixDescribe(*MeshB.matrix);
/*
Describe matrix:
|1.000000 0.000000 0.000000 0.000000|
|0.000000 1.000000 0.000000 0.000000|
|0.000000 0.000000 1.000000 90.000000|
|0.000000 0.000000 0.000000 1.000000|
*/
// The numbers are nicer, but still wrong or I'm wrong


So, what is happening in the methods rotateWithMatrix: and rotateWithQuaternion:quat: and what is the correct way to get MeshB.matrix equal to MeshA.matrix?
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.