I think I understand that most vectors are simply positions, (presumably coordinates? The star the origin?) and there are also velVectors, which are velocities with a speed and direction.
Also, am I right in saying that in most cases you can use a SpaceObject in place of a position vector?
If position vectors are simply positions, then what are the functions for adding vectors and subtracting vectors for? Are they only for dealing with velVectors? I can't see a particular use for adding two sets of coordinates together, unless position vectors can be relative, not absolute from the origin of the system.
The code I have an issue with is a bit of gravity. All is well and good when I get the planets and ships to orbit the sun, but I can't seem to get the distance between gSource and the nearest "planet". The planet is a ship with a certain tag. Without the distance between the two objects, I can't get anything to work.
These are the lines of code that cannot be made to work:
Code: Select all
(block (strength TickSkip ThePlanet)
(setq TickSkip (ObjGetData gsource "Tickskip"))
(setq ThePlanet (sysfindobject gsource "NB:Planet"))
(setq strength (divide (multiply TickSkip 10000) (power (objgetdistance ThePlanet gSource) 2)))
(if (eq strength 0)
(ObjIncData gSource "TickSkip" 1)
(block nil
(ObjSetData gSource "TickSkip" 1)
(ObjincVel gsource (sysVectorPolarVelocity (add (sysVectorAngle (objGetPos gSource)) 180) strength))
)
)
)
Code: Select all
(block (strength TickSkip TheStar)
(setq TickSkip (ObjGetData gsource "Tickskip"))
(setq strength (divide (multiply TickSkip 10000) (power (sysVectorDistance gSource) 2)))
(if (eq strength 0)
(ObjIncData gSource "TickSkip" 1)
(block nil
(ObjSetData gSource "TickSkip" 1)
(ObjincVel gsource (sysVectorPolarVelocity (add (sysVectorAngle (objGetPos gSource)) 180) strength))
)
)
)
TL:DR
Can't make code for finding distance between two space objects, one of which is gsource and the other the nearest with a certain attribute.
Help me understand vectors please
