RFC: Fancy classics

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Simon B wrote:
The rear gun on the anaconda is requires the subent rotated 152deg about (1,0,0). Hence the quarternion is: (0.2419 0.9703 0.0000 0.0000).

However, the port gun requires the subent rotated -90 deg about (1,0,0) and then -30deg = +330deg about (0,0,1)... those rotations are:

Q1 = (1,-1,0,0) since cos(45) = sin(45) = 1/sqrt(2);
Q2 = (1,0,0,t) where t = sin(-15)/cos(-15) = -tan(15) = -0.26795
When you use the console you can use a lot of Oolites internal quaternion calculations. like:

Code: Select all

> new Quaternion([0, 1, 0, 0]).rotate([1,0,0], 152/180*Math.PI)
(-0.970296 + 0.241922i - 0j - 0k)

or

new Quaternion([1, 0, 0, 0]).rotate([1,0,0], 152/180*Math.PI)
(0.241922 + 0.970296i - 0j - 0k)
This last is what you calculated.

With your other calculation I got different results.

Code: Select all

> new Quaternion([1, 0, 0, 0]).rotate([1,0,0], -90/180*Math.PI).rotate([0,0,1], -30/180*Math.PI)
(0.683013 - 0.683013i - 0.183013j - 0.183013k)
But when I normalise your results I get the same result (only one different sign):

Code: Select all

> new Quaternion([1, -1, -0.26795, 0.26795]).normalize()
(0.683013 - 0.683013i - 0.183013j + 0.183013k)
And your quaternion is only valid for use after normalisation.

No need to use complex spreadsheets. The console is enough.
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Right now I'm working through the models one at a time ... there must have been something wrong with the plist or something because copying over another one removed the error.... note, copying over the contents did not, I had to copy the whole file.

The player anaconda turrets won't shoot at anything, but they do point at opponents - what did I miss? (Not tested )
Eric Walch wrote:
Simon B wrote:
The rear gun on the anaconda is requires the subent rotated 152deg about (1,0,0). Hence the quarternion is: (0.2419 0.9703 0.0000 0.0000).

However, the port gun requires the subent rotated -90 deg about (1,0,0) and then -30deg = +330deg about (0,0,1)... those rotations are:

Q1 = (1,-1,0,0) since cos(45) = sin(45) = 1/sqrt(2);
Q2 = (1,0,0,t) where t = sin(-15)/cos(-15) = -tan(15) = -0.26795
When you use the console you can use a lot of Oolites internal quaternion calculations.
Anyone used that console under a gnu/linux?
like:

Code: Select all

> new Quaternion([0, 1, 0, 0]).rotate([1,0,0], 152/180*Math.PI)
(-0.970296 + 0.241922i - 0j - 0k)
[/quote]

(0,1,0,0) is a 180deg rotation about x
(1,0,0) is x
152/180*math.PI = 152 degrees converted to radiens.

this next one is more like how I thought the console would work for this calculation.[quote]
new Quaternion([1, 0, 0, 0]).rotate([1,0,0], 152/180*Math.PI)
(0.241922 + 0.970296i - 0j - 0k)
This last is what you calculated.
Starting with (1,0,0,0) or zero degree rotation.
With your other calculation I got different results.

Code: Select all

> new Quaternion([1, 0, 0, 0]).rotate([1,0,0], -90/180*Math.PI).rotate([0,0,1], -30/180*Math.PI)
(0.683013 - 0.683013i - 0.183013j - 0.183013k)
But when I normalise your results I get the same result (only one different sign):

Code: Select all

> new Quaternion([1, -1, -0.26795, 0.26795]).normalize()
(0.683013 - 0.683013i - 0.183013j + 0.183013k)
And your quaternion is only valid for use after normalisation.
Please note that Oolite normalises the quarternons when it loads them. Also, the actual numbers are not what gives the rotation, but the relatioship between them. So (100,-100,0,0) is the same rotation as (1,-1,0,0). Either can be used. The math is simpler with normalised Qs.

That's why I can do:

Q = (cos(A),Rsin(A)) = (1, Rtan(A)) ... where R is the rotation vector and A is the half-angle.

The difference in sign is important, though, unless all the elements change sign. It changes the direction of the rotation.
No need to use complex spreadsheets. The console is enough.
I'll agree that spreadsheets tend to over-complicate calculations that do not involve manipulating columns of figures (geometry, say) but the console still needs me to know the rotation angle.

The octave/matlab thing I'm fiddling with finds the angle for you. The idea is to solve the issue Griff lamented - where you spend hours fiddling with the models in wings3D or whatever, to record the rotation-angle sets and then multiplying quarternions.

If you have a one-step way to work out the angle and rotation axis you are set. It should be easy to convert the m-file script and add this function to the console.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Diziet Sma wrote:
Simon B wrote:
I note that nobody has commented on how overarmed that anaconda is ...
I wouldn't say it was over-armed... I would however, suggest that maybe it's time somebody came up with a more compact design for plasma cannons, those things must be HUGE!
The cannons are 9m long ;) It's about as small as I can get and still have it show up at decent ranges. Even so, the blue bits are important for locating them. (It's likely I'll end up putting the base in the normalmap, so players can shoot the cannon off the ship without it looking silly when you blast a base.)

But But griffs spacebar cannons are almost as long as the anaconda!

Bear in mind that plasma cannon can have just about any weapon power!
Love the Station, btw, that will look awesome when finished.
I thing, in light of what followed, that it should be pointed out that "huge" is a relative term.

Also, oolite has scale, um, issues anyway. How big is a planet in oolite?

The star is the biggest thing in the game (so far) ... but it is not exactly stellar-sized and probably shouldn't be. The biggest object in the default plist is a station ... this ship is, intentionaly, station-sized.

Actually, it has about 15% of the volume of the coriolis I pictured it with.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

I stand corrected - the turrets are not tracking enemies - they just sit their and quivver. I'm missing a script right? An entry in the AI - where's the griff boa when I need it.
Last edited by Simon B on Fri May 08, 2009 6:32 am, edited 1 time in total.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Simon B wrote:
Anyone used that console under a gnu/linux?
Yup, runs quite happily on my Ubuntu box. In the download there's a python script that you need to run (ignore the .exe, that's the doze version). Iirc you need to install the twisted python package plus I think another one, it's detailed in the docs about the debug console itself.
Simon B wrote:
I thing, in light of what followed, that it should be pointed out that "huge" is a relative term.

Also, oolite has scale, um, issues anyway. How big is a planet in oolite?

The star is the biggest thing in the game (so far) ... but it is not exactly stellar-sized and probably shouldn't be. The biggest object in the default plist is a station ... this ship is, intentionaly, station-sized.

Actually, it has about 15% of the volume of the coriolis I pictured it with.
It varies from planet to planet, but from memory its effectively somewhere between 30km and 70km in equivalent terms to a Wings3D model. The standard stations are 1km diameter for reference.
Simon B wrote:
I stand corrected - the turrets are not tracking enemies - they just sit their and quivver. I'm missing a script right?
They need the start-up action to initialiseTurret, and I think perhaps the role ballturret (not 100% sure on the latter, but all turrets I've seen have had that role). No script or AI is needed.
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Thargoid wrote:
It varies from planet to planet, but from memory its effectively somewhere between 30km and 70km in equivalent terms to a Wings3D model. The standard stations are 1km diameter for reference.The coriolis station model is 500m across (front-to-back.) I've just had rather a lot to do with it.

Note that my big carrier is bigger than the coriolis, at 780-odd meters? I'me considering just slotting that model into the behemoth oxp, with appropriate mods, see what happens.

That suggests I'll need a navy viper model too ... though I was going to use asps, or maybe dual-gun sidewinders.
Simon B wrote:
I stand corrected - the turrets are not tracking enemies - they just sit their and quivver. I'm missing a script right?
They need the start-up action to initialiseTurret, and I think perhaps the role ballturret (not 100% sure on the latter, but all turrets I've seen have had that role). No script or AI is needed.
... hmmm... roles = ballturret did the trick. Curious - griffs spacebar turrets don't use it.

Definately lethal - only shoots at an acquired target but ye gods it don't last long!

I gave the std turrets power 9 (plasma guns are supposed to be 6) but the two under the nose are heavy guns at power 23. The speed and the turrets are making this fun to play.

Find the current version in the neolite-concepts package.

The npc version has two suped-up military lasers (non-turret) under the nose instead. (They don't turn fast and have a non-aggressive ai, so if you're silly enough to get in front of one... also means it has a blind spot on the belly ;) )

Possibly I need to balance the power - though anacondas don't half draw fire.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Simon B wrote:
The coriolis station model is 500m across (front-to-back.) I've just had rather a lot to do with it.
In the file new_coriolis.dat, the Lord Giles wrote:
VERTEX
500, 0, 500
0, 500, 500
-500, 0, 500
0, -500, 500
500, -500, 0
500, 500, 0
-500, 500, 0
-500, -500, 0
500, 0, -500
0, 500, -500
-500, 0, -500
0, -500, -500
32, -96, 500
32, 96, 500
-32, 96, 500
-32, -96, 500
Looks like +500 to -500 to me, which by my count is 1000m ;)
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Simon B wrote:
The octave/matlab thing I'm fiddling with finds the angle for you. The idea is to solve the issue Griff lamented - where you spend hours fiddling with the models in wings3D or whatever, to record the rotation-angle sets and then multiplying quarternions.
Simon,

With js you can define a globally valid function in Oolite. Create an private oxp containing a js script with following function definition:

Code: Select all

function toQuaternion(pos1, pos2, pos3)
{
	var v1, v2, v3, n, r
	var a
	var q = new Quaternion([1,0,0,0])
	v1 = new Vector3D(pos1).subtract(new Vector3D(pos2))
	v2 = new Vector3D(pos2).subtract(new Vector3D(pos3))
	v3 = new Vector3D([0,0,1])
	n = v1.cross(v2).direction()
	r = v3.cross(n)
	if(r.x==0 && r.y==0 && r.z==0) return q;
	a = v3.angleTo(n)
	log("private function", "Normal = "+n+", rotation axis = "+r+", angle = "+a)
	return q.rotate(r, a)
}
This function accepts the three corner-points of your plane you want the cross (=normal) vector from. Than it calculates the angle needed to rotate this far and rotates the unity quaternion to this position.

This global function can now be used by any oxp, thus also by the console. When I now call the function in the console I get:

Code: Select all

> toQuaternion([1,1,1], [1,1,-1], [1,-1,1])
Normal = (-1, 0, 0), rotation axis = (0, -1, 0), angle = 1.5707963705062866
(0.707107 - 0i - 0.707107j - 0k)

> toQuaternion([1,1,1], [1,-1,1], [-1,1,1])
(1 - 0i - 0j - 0k)

I think this does all you want. You only have to watch the sign as it depends on the list order of the three coordinates. (listed clock or anti clockwise)
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Thargoid wrote:
Simon B wrote:
The coriolis station model is 500m across (front-to-back.) I've just had rather a lot to do with it.
In the file new_coriolis.dat, the Lord Giles wrote:
VERTEX
500, 0, 500
0, 500, 500
-500, 0, 500
Apparently I had not quite enough to do with this station - when you are right you are right. Which means that my comparison (prev pic) is out ... the big ship is a little longer than coriolis, and narrower.

I think it must have been the dock subent entry that fooled me.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Eric Walch wrote:
I think this does all you want. You only have to watch the sign as it depends on the list order of the three coordinates. (listed clock or anti clockwise)
It does indeed - well done.

Better test that in the game - the best part is that it uses oolites internal math (did I get that right) so no need to second guess the left-handedness. Just remember to put a minus sign on all x-coordinate entries.

Now all I'm looking for is the script snippet which spawns a test ship by the witchpoint when you jump in. Needed to test da big ship.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Simon B wrote:
Now all I'm looking for is the script snippet which spawns a test ship by the witchpoint when you jump in. Needed to test da big ship.

Code: Select all

this.name	= "Ship_Spawn_Script";
this.author	= "Thargoid";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike.";
this.description = "Spawns a ship near the witchpoint on arrival";
this.version = "1.0";

this.shipWillExitWitchspace = function()
{
system.legacy_addShipsWithinRadius("<insert ship role here>", 1, "wpm", [0,0,0], 20000);
}
Save that as script.js in the Config folder of a suitable OXP, and replace <insert ship role here> with the role of your ship you want to appear (within quotation marks still).
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

If you are running the console, you can spawn any ship any time by simply doing

Code: Select all

:spawn shipRole
replacing shipRole with the actual role of the ship you want. This is a macro that runs a command quite similar to Thargoid's script, only difference being that you can execute it at will and the ship is spawned near the player instead of the witchpoint.
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

Great - that works fine ... everything works ... all is well and happiness pervades the ooniverse. :D

Image

Image

Still to do - add normalmap and turrets.

Anyone want to do a skin for a Navy Viper?

And - in case anyone is wondering ...
Image

Image
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

:shock: 8) Fabulous Fabulous work Simon - I bow down to your skill and dedication to the cause!
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Post by pagroove »

Great work. I like the new model. Comes nicely along with the Superhub or Orbitopolis. 2 new stations for Oolite. See Orisis Tread.
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
Post Reply