Homebrew Citro3D: How to apply quaternions to your object?

delete12345

Well-Known Member
OP
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
Citro3D now supports quaternions.

When you create a new quaternion, what do you do with it, so you can apply rotations to your object?

And do you have to do it inside the PICA vertex shader?
 

catlover007

Developer
Developer
Joined
Oct 23, 2015
Messages
719
Trophies
1
XP
3,905
Country
Germany
well you have multiple options.
The easier one would be to convert your quaternion to a matrix and multiply your modelView matrix with it, which you pass into the vertex shader.
Another option(the more difficult but better option) would be to pass the quaternion to your vertex shader and use magic quaternion math(which you have to copy and translate to Pica assembler by yourself from the source code of c3d, see here: https://github.com/fincs/citro3d/blob/master/source/maths/quat_crossfvec3.c) to apply the rotation to your vertices(watch out for the order, first rotate then translate).
 
  • Like
Reactions: marc00077

delete12345

Well-Known Member
OP
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
what are you going to do? I'm a little bit confused the first way or the second?

Using quaternions to move around in the world. Not relying on matrix transformations as much as possible. This is to force myself to learn about quaternions and trying to embed the big picture of using it into my brain, so I can get past the hurdles for thinking about it conceptually.
 

pigman46

Member
Newcomer
Joined
Jun 23, 2009
Messages
9
Trophies
0
XP
168
Country
United States
ah, ok. I never really understood how they work internally.

Good luck

Don't try to understand how they work internally. It's a 4-dimensional abstraction where three of the dimensions are imaginary. You only need to understand what their operations accomplish.

--------------------- MERGED ---------------------------

Using quaternions to move around in the world.

Quaternions are orientations; they do not include position. You can use quats to "move" rotationally. You need to translate using the result from cross multiplying with a vector if you want to use them for moving position.

Not relying on matrix transformations as much as possible.

Yes. Quat+Vec3 (orientation plus position) uses less memory than a 4x4 matrix. Additionally, quat operations are cheaper than their equivalent matrix operations. Plus you have the whole reason they were invented: the quotient of two rotations. This allows you to slerp between two orientations. You can't do this (generically) at all with matrix math.
 

koz

Well-Known Member
Newcomer
Joined
Jul 7, 2015
Messages
86
Trophies
0
Age
48
XP
137
Country
Using quaternions to move around in the world. Not relying on matrix transformations as much as possible. This is to force myself to learn about quaternions and trying to embed the big picture of using it into my brain, so I can get past the hurdles for thinking about it conceptually.

I liked this math series about quaternions by Professor Norman Wildberger at UNSW (Australia).

https://www.youtube.com/user/njwildberger/search?query=quaternions

Start here:
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    NinStar @ NinStar: It will actually make it worse