Quaternions

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
ClymAngus
---- E L I T E ----
---- E L I T E ----
Posts: 2508
Joined: Tue Jul 08, 2008 12:31 am
Location: London England
Contact:

Quaternions

Post by ClymAngus »

I was looking for a way to quickly calculate quaternions for singular and 2 stage rotations.

Taking a look on the website I boiled down and weaponized the equations into a spread sheet. It's a little specialized I know but it saves dicking around for half an hour with a calculator.

www.crimsonforge.co.uk/cloister/Quaternion.xls
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Quaternions

Post by Eric Walch »

ClymAngus wrote:
I was looking for a way to quickly calculate quaternions for singular and 2 stage rotations.
You could look in BuoyRepair.oxp. In the script buoyRepair.js in the function this.addStation = function() I manipulate the station by rotating it in such a way that it orients to the planet as wel as to the main station.

I hope you can use these examples
User avatar
ClymAngus
---- E L I T E ----
---- E L I T E ----
Posts: 2508
Joined: Tue Jul 08, 2008 12:31 am
Location: London England
Contact:

Re: Quaternions

Post by ClymAngus »

Eric Walch wrote:
ClymAngus wrote:
I was looking for a way to quickly calculate quaternions for singular and 2 stage rotations.
You could look in BuoyRepair.oxp. In the script buoyRepair.js in the function this.addStation = function() I manipulate the station by rotating it in such a way that it orients to the planet as wel as to the main station.

I hope you can use these examples
Cool. I wasn't thinking real time (I just need it to enhance some ship views so the spread sheets fine but, I'll take a look it's a very useful thing.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

this might be of help for real time, it will orientate a ship toward the targetObject

Code: Select all


//for pre 1.73
this.aship.setOrientation(this.aship, this.orientationTo(targetObject))
//for after 1.73
this.aship.orientation(this.aship, this.orientationTo(targetObject))


this.orientationTo = function(centre, targetObject)
{	
        let vectorToTarget = targetObject.position.subtract(centre.position)
        let forwardVector = centre.orientation.vectorForward() 
        let angle = forwardVector.angleTo(vectorToTarget)
        let cross = forwardVector.cross(vectorToTarget).direction()
        let q = this.rotateQ(centre.orientation, cross, -angle)
        return q
}
Bounty Scanner
Number 935
Post Reply