Stormworks: Build and Rescue

Stormworks: Build and Rescue

Not enough ratings
SO(3) R^3 Euclidean Space Rotation Flight Sim DEMO
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
371.281 KB
Jul 5, 2024 @ 6:06pm
Jul 7, 2024 @ 1:48pm
5 Change Notes ( view )

Subscribe to download
SO(3) R^3 Euclidean Space Rotation Flight Sim DEMO

In 1 collection by Kernle Frizzle
Lua, etc.
8 items
Description
Activate engine with 4. Use controls as labeled. Flap position and engine RPM are shown on the debug panel to the left, main flight instruments are in front of you. "ias" is airspeed in knots, "alt ft" is altitude in feet, "comp" is your compass heading (negative to get the dial to turn the right way), "vs fpmx100" is vertical speed in feet per minute, 1 = 100fpm.

This is set up to simulate an aircraft similar to a Cessna 152. I'm not an aeronautical engineer so it isn't 100% physically accurate (as usual) but I think it's pretty close.

[INF ELEC ADVISED]

my brain has melted
If you like toying around with lua and have experience with artificial horizons and other systems requiring the position and orientation of an aircraft or other vehicle, then there's a chance this can be helpful.

What the hell does that title mean?
In mechanics and geometry, the 3D rotation group, often donated SO(3), is the group of all rotations about the origin of three-dimensional Euclidean space R3 under the operation of composition. That's the first line of the Wikipedia for "3D rotation group."

Essentially, this demo uses matrix operations on vectors to calculate orientations based on inputted rates of rotation around the three directional axis with reference to a simulated aircraft. Only instead of the efficient way of using a 3x3 rotation matrix that deals with all axis at the same time, it uses three separate matrix rotations, one for each cardinal direction, x y and z. This is just because I'm lazy and don't want to do the research on how to compose or apply those matrices onto vectors.

In the real world, whenever a mathematical representation of a rotation is needed, whether it be for computer graphics or physics simulations, usually these funky things called quaternions are used. These aren't important for this, but they're important to mention as they are much more reliable than the stinky smelly easier to understand real world rotation. Quaternions, like vectors and matrices, are just another mathematical way to represent an orientation which may have it's own physical meaning. Instead of containing just three dimensions, x y and z, quaternions contain a fourth dimension because why the hell not. Oh, and they're represented with imaginary components and therefore follow imaginary rules. Those rules make them much simpler mathematically but impossible to comprehend in a physical sense.

TLDR
This demo shows a way that coordinate vector rotations can be computed in lua. It is set up to simulate the rotations a plane may undergo. wasd+lr control the plane in the same way you would a real plane ingame. If you're thinking of making a true fully simulated flight simulator, this is one of the necessary things you will have to deal with.

What are all the pistons?
In the center of the vehicle is a representation of the three coordinate axis, x y and z, red green and blue respectively, centered around a pink T-piece representing an aircraft. In order to calculate the rotation from the point of view of the aircraft, it has to rotate the coordinate space itself instead. You can see how the axis rotate around the aircraft as you bank and turn. Fun fact, the x axis isn't even used for the calculation of the aircraft's orientation, it's just there for looks.

Each axis is represented with a 3D vector, the direction of which corresponding to the orientation of the axis. This makes it very convenient to show the current position of every axis as you can just feed those orientations straight into a robotic structure that will move something to that vector's position. That's what each piston does. One alone for each axis is too floppy though, so I had to double them up to strengthen them.

To the right of the seat is the physical representation of the aircraft being simulated. Playing around with it you can see how it will rotate about it's own plane (coordinate plane, not plane-plane). Getting that behavior is the whole purpose of this demo.

If you want to somehow use this clusterf*ck of lua in your own creation, just note that the i j and k tables represent the normal vectors (unused in this), i1 j1 and k1 represent the transformed normal vectors relative to the aircraft, and everything else is just used for computing the roll, pitch and yaw of the aircraft relative to the normal vectors, the space.

As always I'm sure there's a better more efficient way to do this, for example true axis-angle rotations, but what the hell this works too yippe yahoo hooray

if you have any questions,
like comment subscribe or i will rotmat2d() your car
3 Comments
DinoDude777 Jul 20, 2024 @ 11:37pm 
real
Kernle Frizzle  [author] Jul 20, 2024 @ 10:37pm 
you wont BELIEVE what happens next
DinoDude777 Jul 20, 2024 @ 4:05pm 
100% real not clickbait thumbnail lookin