• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Quaternion library

Juju

Member
Whilst the current beta has some pretty extreme limitations, it's still possible to build and test in it. To demonstrate the new array literals, as well as to experiment a bit with the matrix functions, I've built a quaternion library. It doesn't have particularly fancy features but it does the basic rotation operations competently and cleanly.

Available as a GitHub repo
Current version: 2016/07/11
Code:
MIT License
Copyright (c) 2016 @jujuadams

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
Last edited:

chance

predictably random
Forum Staff
Moderator
@Juju: this is a nice example. I generally just use Euler rotations (or products of them) around the X-Y-Z axes. But the quaternion approach is slicker. So thanks for this example. It's well organized and easy to follow, like other examples you've provided.

(btw, there's a typo in Line 12 in the quaternion_rotate_vector script. )
 
Top