# HomebrewCitro3D: How to apply quaternions to your object?

#### delete12345

##### Well-Known Member
OP
Member
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?

#### SimplyFedorable

##### Evangelion Geek
Member
Compelty off topic, but it is Citra, not Citro

Member

#### catlover007

##### Developer
Developer
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).

marc00077

#### delete12345

##### Well-Known Member
OP
Member

What should the C3D_FVec argument be? I remembered vaguely that it's for forward, up, and right, but I would like for confirmation.

#### catlover007

##### Developer
Developer
The q is the quaternion which represents the rotation and v is the vector that should be rotated(around point zero)

#### delete12345

##### Well-Known Member
OP
Member
The q is the quaternion which represents the rotation and v is the vector that should be rotated(around point zero)

Ah, then I may be mistakenly referring to FVec3_CrossQuat(v, q) instead? Thanks for the info.

#### catlover007

##### Developer
Developer
what are you going to do? I'm a little bit confused the first way or the second?

#### delete12345

##### Well-Known Member
OP
Member
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.

#### catlover007

##### Developer
Developer
ah, ok. I never really understood how they work internally.

Good luck

#### pigman46

##### Member
Newcomer
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.

#### YugamiSekai

##### Mr. Picross
Member
How do you even use Citro3D? And why do we need shader files?

#### koz

##### Well-Known Member
Newcomer
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).

Start here:

#### delete12345

##### Well-Known Member
OP
Member
How do you even use Citro3D? And why do we need shader files?

You will have to look up the example codes provided with a devkitPro installation. Citro3D is like OpenGL ES 2.0, hence the shader files. (Analogy only)

Replies
2
Views
578
Replies
0
Views
310
Replies
2
Views
743
Replies
7
Views
669
Replies
11
Views
1K

1. 28K views

### New static recompiler tool N64Recomp aims to seamlessly modernize N64 games

As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The...
2. 25K views

### Nintendo officially confirms Switch successor console, announces Nintendo Direct for next month

While rumors had been floating about rampantly as to the future plans of Nintendo, the President of the company, Shuntaro Furukawa, made a brief statement confirming...
3. 23K views

### TheFloW releases new PPPwn kernel exploit for PS4, works on firmware 11.00

TheFlow has done it again--a new kernel exploit has been released for PlayStation 4 consoles. This latest exploit is called PPPwn, and works on PlayStation 4 systems...
4. 22K views

### Nintendo takes down Gmod content from Steam's Workshop

Nintendo might just as well be a law firm more than a videogame company at this point in time, since they have yet again issued their now almost trademarked usual...
5. 21K views

### Name the Switch successor: what should Nintendo call its new console?

Nintendo has officially announced that a successor to the beloved Switch console is on the horizon. As we eagerly anticipate what innovations this new device will...
6. 17K views

### A prototype of the original "The Legend of Zelda" for NES has been found and preserved

Another video game prototype has been found and preserved, and this time, it's none other than the game that spawned an entire franchise beloved by many, the very...
7. 14K views

### DOOM has been ported to the retro game console in Persona 5 Royal

DOOM is well-known for being ported to basically every device with some kind of input, and that list now includes the old retro game console in Persona 5 Royal...
8. 12K views

### AYANEO officially launches the Pocket S, its next-generation Android gaming handheld

Earlier this year, AYANEO revealed details of its next Android-based gaming handheld, the AYANEO Pocket S. However, the actual launch of the device was unknown; that...
9. 11K views

### Delta emulator for iOS will support iPad devices in its next update

With just a couple weeks after its initial release in the App Store, the Delta emulator for iOS was received with great success, after Apple loosened up its rules in...
10. 11K views

### Anbernic reveals the RG35XXSP, a GBA SP-inspired retro handheld

Retro handheld manufacturer Anbernic has revealed its first clamshell device: the Anbernic RG35XXSP. As the suffix indicates, this handheld's design is inspired by...
1. 293 replies

### Name the Switch successor: what should Nintendo call its new console?

Nintendo has officially announced that a successor to the beloved Switch console is on the horizon. As we eagerly anticipate what innovations this new device will...
2. 232 replies

### Nintendo officially confirms Switch successor console, announces Nintendo Direct for next month

While rumors had been floating about rampantly as to the future plans of Nintendo, the President of the company, Shuntaro Furukawa, made a brief statement confirming...
3. 133 replies

### New static recompiler tool N64Recomp aims to seamlessly modernize N64 games

As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The...
4. 129 replies

### Nintendo takes down Gmod content from Steam's Workshop

Nintendo might just as well be a law firm more than a videogame company at this point in time, since they have yet again issued their now almost trademarked usual...
5. 95 replies

### Ubisoft reveals 'Assassin's Creed Shadows' which is set to launch later this year

Ubisoft has today officially revealed the next installment in the Assassin's Creed franchise: Assassin's Creed Shadows. This entry is set in late Sengoku-era Japan...
6. 87 replies

### The Kingdom Hearts games are coming to Steam

After a little more than three years of exclusivity with the Epic Games Store, Square Enix has decided to bring their beloved Kingdom Hearts franchise to Steam. The...
7. 80 replies

### TheFloW releases new PPPwn kernel exploit for PS4, works on firmware 11.00

TheFlow has done it again--a new kernel exploit has been released for PlayStation 4 consoles. This latest exploit is called PPPwn, and works on PlayStation 4 systems...
8. 78 replies

### "Nintendo World Championships: NES Edition", a new NES Remix-like game, launching July 18th

After rumour got out about an upcoming NES Edition release for the famed Nintendo World Championships, Nintendo has officially unveiled the new game, titled "Nintendo...
9. 71 replies

### DOOM has been ported to the retro game console in Persona 5 Royal

DOOM is well-known for being ported to basically every device with some kind of input, and that list now includes the old retro game console in Persona 5 Royal...
10. 65 replies

### Microsoft is closing down several gaming studios, including Tango Gameworks and Arkane Austin

The number of layoffs and cuts in the videogame industry sadly continue to grow, with the latest huge layoffs coming from Microsoft, due to what MIcrosoft calls a...