@@ -32,7 +32,7 @@ crossProduct = (a, b) ->
32
32
33
33
normalize = (v ) -> numeric .divVS (v, numeric .norm2 (v))
34
34
35
- projectToPlane = (p , n ) -> numeric .subVV (p, numeric .mulSV (numeric .dot (p, n), n))
35
+ projectToPlane = (p , n ) -> numeric .subVV (p, numeric .mulSV (numeric .dotVV (p, n), n))
36
36
37
37
angleInPlane = (from , to , normal ) ->
38
38
from = normalize (projectToPlane (from , normal))
@@ -125,11 +125,11 @@ newtonsMethod = (x0, f, df) ->
125
125
n = @ normalVector ()
126
126
p1 = @ positionAtTrueAnomaly (@ trueAnomalyAt (t))
127
127
p2 = orbit .positionAtTrueAnomaly (orbit .trueAnomalyAt (t))
128
- p2 = numeric .subVV (p2, numeric .mulVS (n, numeric .dot (p2, n))) # Project p2 onto our orbital plane
128
+ p2 = numeric .subVV (p2, numeric .mulVS (n, numeric .dotVV (p2, n))) # Project p2 onto our orbital plane
129
129
r1 = numeric .norm2 (p1)
130
130
r2 = numeric .norm2 (p2)
131
- phaseAngle = Math .acos (numeric .dot (p1, p2) / (r1 * r2))
132
- phaseAngle = TWO_PI - phaseAngle if numeric .dot (crossProduct (p1, p2), n) < 0
131
+ phaseAngle = Math .acos (numeric .dotVV (p1, p2) / (r1 * r2))
132
+ phaseAngle = TWO_PI - phaseAngle if numeric .dotVV (crossProduct (p1, p2), n) < 0
133
133
phaseAngle = phaseAngle - TWO_PI if orbit .semiMajorAxis < @semiMajorAxis
134
134
phaseAngle
135
135
@@ -262,7 +262,7 @@ Orbit.fromPositionAndVelocity = (referenceBody, position, velocity, t) ->
262
262
nodeVector = normalize ([- specificAngularMomentum[1 ], specificAngularMomentum[0 ], 0 ]) # Eq. 5.22
263
263
else
264
264
nodeVector = [1 , 0 , 0 ]
265
- eccentricityVector = numeric .mulSV (1 / mu, numeric .subVV (numeric .mulSV (v* v - mu / r, position), numeric .mulSV (numeric .dot (position, velocity), velocity))) # Eq. 5.23
265
+ eccentricityVector = numeric .mulSV (1 / mu, numeric .subVV (numeric .mulSV (v* v - mu / r, position), numeric .mulSV (numeric .dotVV (position, velocity), velocity))) # Eq. 5.23
266
266
267
267
semiMajorAxis = 1 / (2 / r - v * v / mu) # Eq. 5.24
268
268
eccentricity = numeric .norm2 (eccentricityVector) # Eq. 5.25
@@ -275,11 +275,11 @@ Orbit.fromPositionAndVelocity = (referenceBody, position, velocity, t) ->
275
275
else
276
276
orbit .longitudeOfAscendingNode = Math .acos (nodeVector[0 ]) # Eq. 5.27
277
277
orbit .longitudeOfAscendingNode = TWO_PI - orbit .longitudeOfAscendingNode if nodeVector[1 ] < 0
278
- orbit .argumentOfPeriapsis = Math .acos (numeric .dot (nodeVector, eccentricityVector) / eccentricity) # Eq. 5.28
278
+ orbit .argumentOfPeriapsis = Math .acos (numeric .dotVV (nodeVector, eccentricityVector) / eccentricity) # Eq. 5.28
279
279
orbit .argumentOfPeriapsis = TWO_PI - orbit .argumentOfPeriapsis if eccentricityVector[2 ] < 0
280
280
281
- trueAnomaly = Math .acos (numeric .dot (eccentricityVector, position) / (eccentricity * r)) # Eq. 5.29
282
- trueAnomaly = - trueAnomaly if numeric .dot (position, velocity) < 0
281
+ trueAnomaly = Math .acos (numeric .dotVV (eccentricityVector, position) / (eccentricity * r)) # Eq. 5.29
282
+ trueAnomaly = - trueAnomaly if numeric .dotVV (position, velocity) < 0
283
283
284
284
meanAnomaly = orbit .meanAnomalyAtTrueAnomaly (trueAnomaly)
285
285
orbit .timeOfPeriapsisPassage = t - meanAnomaly / orbit .meanMotion ()
@@ -344,9 +344,9 @@ ejectionAngle = (vsoi, theta, prograde) ->
344
344
345
345
prograde = [prograde[0 ], prograde[1 ], 0 ] # Project the prograde vector onto the XY plane
346
346
if crossProduct ([vx, vy, 0 ], prograde)[2 ] < 0
347
- TWO_PI - Math .acos (numeric .dot ([vx, vy, 0 ], prograde))
347
+ TWO_PI - Math .acos (numeric .dotVV ([vx, vy, 0 ], prograde))
348
348
else
349
- Math .acos (numeric .dot ([vx, vy, 0 ], prograde))
349
+ Math .acos (numeric .dotVV ([vx, vy, 0 ], prograde))
350
350
351
351
Orbit .transfer = (transferType , originBody , destinationBody , t0 , dt , initialOrbitalVelocity , finalOrbitalVelocity , p0 , v0 , n0 , p1 , v1 , planeChangeAngleToIntercept ) ->
352
352
# Fill in missing values
@@ -382,7 +382,7 @@ Orbit.transfer = (transferType, originBody, destinationBody, t0, dt, initialOrbi
382
382
# in the target position rotated into the origin plane as the plane change axis changes.
383
383
# This approximation should be valid so long as the transfer orbit's semi-major axis and eccentricity
384
384
# does not change significantly with the change in the plane change axis.
385
- relativeInclination = Math .asin (numeric .dot (p1, n0) / numeric .norm2 (p1))
385
+ relativeInclination = Math .asin (numeric .dotVV (p1, n0) / numeric .norm2 (p1))
386
386
planeChangeRotation = quaternion .fromAngleAxis (- relativeInclination, crossProduct (p1, n0))
387
387
p1InOriginPlane = quaternion .rotate (planeChangeRotation, p1)
388
388
v1InOriginPlane = quaternion .rotate (planeChangeRotation, v1)
@@ -409,15 +409,15 @@ Orbit.transfer = (transferType, originBody, destinationBody, t0, dt, initialOrbi
409
409
return Orbit .transfer (" planeChange" , originBody, destinationBody, t0, dt, initialOrbitalVelocity, finalOrbitalVelocity, p0, v0, n0, p1, v1, x)
410
410
else if transferType == " planeChange"
411
411
planeChangeAngleToIntercept ?= HALF_PI
412
- relativeInclination = Math .asin (numeric .dot (p1, n0) / numeric .norm2 (p1))
412
+ relativeInclination = Math .asin (numeric .dotVV (p1, n0) / numeric .norm2 (p1))
413
413
planeChangeAngle = Math .atan2 (Math .tan (relativeInclination), Math .sin (planeChangeAngleToIntercept))
414
414
if planeChangeAngle != 0
415
415
planeChangeAxis = quaternion .rotate (quaternion .fromAngleAxis (- planeChangeAngleToIntercept, n0), projectToPlane (p1, n0))
416
416
planeChangeRotation = quaternion .fromAngleAxis (planeChangeAngle, planeChangeAxis)
417
417
p1InOriginPlane = quaternion .rotate (quaternion .conjugate (planeChangeRotation), p1)
418
418
419
419
# Assume a counter-clockwise transfer around the +z axis
420
- transferAngle = Math .acos (numeric .dot (p0, p1) / (numeric .norm2 (p0) * numeric .norm2 (p1)))
420
+ transferAngle = Math .acos (numeric .dotVV (p0, p1) / (numeric .norm2 (p0) * numeric .norm2 (p1)))
421
421
transferAngle = TWO_PI - transferAngle if p0[0 ] * p1[1 ] - p0[1 ] * p1[0 ] < 0 # (p0 x p1).z
422
422
423
423
if ! planeChangeAngle or transferAngle <= HALF_PI
@@ -507,13 +507,13 @@ Orbit.transferDetails = (transfer, originBody, t0, initialOrbitalVelocity) ->
507
507
n0 = originBody .orbit .normalVector ()
508
508
burnDirection = numeric .divVS (ejectionDeltaVector, ejectionDeltaV)
509
509
510
- transfer .ejectionPitch = Math .asin (numeric .dot (burnDirection, positionDirection))
510
+ transfer .ejectionPitch = Math .asin (numeric .dotVV (burnDirection, positionDirection))
511
511
transfer .ejectionHeading = angleInPlane ([0 ,0 ,1 ], burnDirection, positionDirection)
512
512
513
- progradeDeltaV = numeric .dot (ejectionDeltaVector, progradeDirection)
514
- normalDeltaV = numeric .dot (ejectionDeltaVector, n0)
513
+ progradeDeltaV = numeric .dotVV (ejectionDeltaVector, progradeDirection)
514
+ normalDeltaV = numeric .dotVV (ejectionDeltaVector, n0)
515
515
radialDeltaV = Math .sqrt (ejectionDeltaV* ejectionDeltaV - progradeDeltaV* progradeDeltaV - normalDeltaV* normalDeltaV)
516
- radialDeltaV = - radialDeltaV if numeric .dot (crossProduct (burnDirection, progradeDirection), n0) < 0
516
+ radialDeltaV = - radialDeltaV if numeric .dotVV (crossProduct (burnDirection, progradeDirection), n0) < 0
517
517
518
518
transfer .ejectionProgradeDeltaV = progradeDeltaV
519
519
transfer .ejectionNormalDeltaV = normalDeltaV
@@ -608,14 +608,14 @@ Orbit.courseCorrection = (transferOrbit, destinationOrbit, burnTime, eta) ->
608
608
burnDirection = numeric .divVS (deltaVector, deltaV)
609
609
positionDirection = numeric .divVS (p0, numeric .norm2 (p0))
610
610
611
- pitch = Math .asin (numeric .dot (burnDirection, positionDirection))
611
+ pitch = Math .asin (numeric .dotVV (burnDirection, positionDirection))
612
612
heading = angleInPlane ([0 ,0 ,1 ], burnDirection, positionDirection)
613
613
614
614
progradeDirection = numeric .divVS (v0, numeric .norm2 (v0))
615
- progradeDeltaV = numeric .dot (deltaVector, progradeDirection)
616
- normalDeltaV = numeric .dot (deltaVector, n0)
615
+ progradeDeltaV = numeric .dotVV (deltaVector, progradeDirection)
616
+ normalDeltaV = numeric .dotVV (deltaVector, n0)
617
617
radialDeltaV = Math .sqrt (deltaV* deltaV - progradeDeltaV* progradeDeltaV - normalDeltaV* normalDeltaV)
618
- radialDeltaV = - radialDeltaV if numeric .dot (crossProduct (burnDirection, progradeDirection), n0) < 0
618
+ radialDeltaV = - radialDeltaV if numeric .dotVV (crossProduct (burnDirection, progradeDirection), n0) < 0
619
619
620
620
return {
621
621
correctedVelocity : correctedVelocity
0 commit comments