Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sas off.
- rcs off.
- clearscreen.
- //finds local port.
- set pm1 to ship:modulesnamed("ModuleDockingNode").
- for portmod in pm1 {set myPort to portmod:part.}.
- lock myportposition to myport:position.
- //find target ship's port.
- set pm2 to target:modulesnamed("ModuleDockingNode").
- for portmod in pm2 {set targetPort to portmod:part.}.
- lock targetportposition to targetPort:position.
- // Find axis of rotation, and angle around that axis, to rotate from my ship:facing to my myPort:PORTFACING.
- set rotAngle to VANG( SHIP:FACING:VECTOR, myPort:PORTFACING:VECTOR ).
- set rotAxis to VCRS( SHIP:FACING:VECTOR, myPort:PORTFACING:VECTOR ).
- set rotAxis to rotAxis:NORMALIZED.
- // Splitting the rotAxis into its 3 component parts, in a reference frame that is oriented
- // to match my ship:facing:
- set rotAxisX to VDOT( rotAxis, SHIP:FACING:STARVECTOR ).
- set rotAxisY to VDOT( rotAxis, SHIP:FACING:TOPVECTOR ).
- set rotAxisZ to VDOT( rotAxis, SHIP:FACING:FOREVECTOR ).
- Set runmode to 1.
- until runmode = 0 {
- //finds the angle of the other port (we're using targetPort to make this simple)
- set otherPortRot to targetPort:PORTFACING.
- set otherPortInverseRot to ANGLEAXIS(180,otherPortRot:TOPVECTOR)*targetPort:PORTFACING.
- //should set the correct angle for lock steering
- set otherPortInverseRotAxis to otherPortInverseRot*V( rotAxisX, rotAxisY, rotAxisZ ).
- set myPortRotRelToOther to ANGLEAXIS(-rotAngle,otherPortInverseRotAxis)*otherPortInverseRot.
- //lock steering to lookdirup(target:facing:vector,myPortRotRelToOther:vector).
- lock steering to myPortRotRelToOther.
- //This is trying to set a vector from myport:facing to the target port position, then finding the angles.
- lock myporttotargetport to (myport:facing*targetportposition).
- lock myporttotargetangleZangle to vang(myport:facing:vector,myporttotargetport).
- lock myporttotargetangleXangle to vang(myport:facing:starvector, myporttotargetport).
- lock myporttotargetangleYangle to vang(myport:facing:upvector, myporttotargetport).
- //This is displaying those vectors above.
- set aa1 to vecdrawargs (myportposition, (myport:facing:starvector)*20, green, "X-STAR-axis", 1, true). //starboard of port
- set aa2 to vecdrawargs (myportposition, (myport:facing:upvector)*20, blue, "Y-UP-axis", 1, true). //up of port.
- set aa3 to vecdrawargs (myportposition, (myPort:facing:vector)*20, red, "Z-FOR-axis", 1, true). //port facing.
- set aa4 to vecdrawargs (targetportposition, (targetPort:portfacing:vector)*20, purple, "axis-of-target port facing", 1, true). //port facing.
- set aa5 to vecdrawargs (myport:position, targetportposition, RGB(1,0.5,0), "Vector from my port to target", 1, true). //port facing to target.
- //This is printing those angles, I'm not sure if the X Y Z are correct.
- print "Zangle " + round(myporttotargetangleZangle,3) at (5,6).
- print "Xangle " + round(myporttotargetangleXangle,3) at (5,7).
- print "Yangle " + round(myporttotargetangleYangle,3) at (5,8).
- } //end runmode, or when runmode = 0.
- sas on.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement