1
- /**
1
+ /*
2
2
predict4java: An SDP4 / SGP4 library for satellite orbit predictions
3
3
4
4
Copyright (C) 2004-2010 David A. B. Johnson, G4DPZ.
@@ -66,10 +66,10 @@ public abstract class AbstractSatellite implements Satellite, Serializable {
66
66
67
67
protected static final double PERIGEE_156_KM = 156.0 ;
68
68
69
- /* WGS 84 Earth radius km */
69
+ /** WGS 84 Earth radius km. */
70
70
protected static final double EARTH_RADIUS = 6.378137E3 ;
71
71
72
- /* Solar radius - km (IAU 76) */
72
+ /** Solar radius - km (IAU 76). */
73
73
protected static final double SOLAR_RADIUS = 6.96000E5 ;
74
74
75
75
private double s4 ;
@@ -84,7 +84,7 @@ public abstract class AbstractSatellite implements Satellite, Serializable {
84
84
private final Vector4 position = new Vector4 ();
85
85
/** Velocity vector of the satellite. Used to store the velocity for later calculations. */
86
86
private final Vector4 velocity = new Vector4 ();
87
- /** Date/time at which the position and velocity were calculated */
87
+ /** Date/time at which the position and velocity were calculated. */
88
88
private double julUTC ;
89
89
/** Satellite position. Used to store the SatPos for later calculations. */
90
90
private SatPos satPos ;
@@ -381,11 +381,9 @@ public synchronized SatPos getPosition(final GroundStationPosition gsPos, final
381
381
382
382
final Vector4 squintVector = new Vector4 ();
383
383
384
- //
385
384
// /** All angles in rads. Distance in km. Velocity in km/S **/
386
385
// /* Calculate satellite Azi, Ele, Range and Range-rate */
387
386
calculateObs (julUTC , position , velocity , gsPos , squintVector );
388
- //
389
387
/* Calculate satellite Lat North, Lon East and Alt. */
390
388
391
389
calculateLatLonAlt (julUTC , position , satPos );
@@ -432,11 +430,11 @@ private static void calculateUserPosVel(final double time,
432
430
final double c = AbstractSatellite .invert (Math .sqrt (1.0 + FLATTENING_FACTOR * (FLATTENING_FACTOR - 2 )
433
431
* AbstractSatellite .sqr (Math .sin (DEG2RAD * gsPos .getLatitude ()))));
434
432
final double sq = AbstractSatellite .sqr (1.0 - FLATTENING_FACTOR ) * c ;
435
- final double achcp = (EARTH_RADIUS_KM * c + ( gsPos .getHeightAMSL () / 1000.0 ) )
433
+ final double achcp = (EARTH_RADIUS_KM * c + gsPos .getHeightAMSL () / 1000.0 )
436
434
* Math .cos (DEG2RAD * gsPos .getLatitude ());
437
435
obsPos .setXYZ (achcp * Math .cos (gsPos .getTheta ()),
438
436
achcp * Math .sin (gsPos .getTheta ()),
439
- (EARTH_RADIUS_KM * sq + ( gsPos .getHeightAMSL () / 1000.0 ) )
437
+ (EARTH_RADIUS_KM * sq + gsPos .getHeightAMSL () / 1000.0 )
440
438
* Math .sin (DEG2RAD * gsPos .getLatitude ()));
441
439
obsVel .setXYZ (-MFACTOR * obsPos .getY (),
442
440
MFACTOR * obsPos .getX (),
@@ -522,13 +520,11 @@ private void calculateObs(final double julianUTC,
522
520
523
521
double elevation = (satPos .getElevation () / Satellite .TWO_PI ) * 360.0 ;
524
522
525
- if (elevation > 0.0 ) {
526
- if (elevation > 90 ) {
527
- elevation = 180 - elevation ;
528
- }
523
+ if (elevation > 0.0 && elevation > 90 ) {
524
+ elevation = 180 - elevation ;
529
525
}
530
526
531
- satPos .setAboveHorizon (( elevation - gsPos .getHorizonElevations ()[sector ]) > EPSILON );
527
+ satPos .setAboveHorizon (elevation - gsPos .getHorizonElevations ()[sector ] > EPSILON );
532
528
}
533
529
534
530
/**
@@ -555,8 +551,8 @@ public boolean willBeSeen(final GroundStationPosition qth) {
555
551
* (2.0 / 3.0 ));
556
552
final double apogee = sma * (1.0 + tle .getEccn ()) - EARTH_RADIUS_KM ;
557
553
558
- return ( Math .acos (EARTH_RADIUS_KM
559
- / (apogee + EARTH_RADIUS_KM )) + ( lin * DEG2RAD )) > Math
554
+ return Math .acos (EARTH_RADIUS_KM
555
+ / (apogee + EARTH_RADIUS_KM )) + lin * DEG2RAD > Math
560
556
.abs (qth .getLatitude () * DEG2RAD );
561
557
}
562
558
@@ -605,19 +601,19 @@ protected void setPerigee(final double perigee) {
605
601
606
602
static class Vector4 extends Object implements Serializable {
607
603
608
- /** serialized id. */
604
+ /** Serialized id. */
609
605
private static final long serialVersionUID = -8804649332186066551L ;
610
606
611
- /** the w part of the vector. ` */
607
+ /** The w part of the vector. ` */
612
608
private double w ;
613
- /** the x part of the vector. ` */
609
+ /** The x part of the vector. ` */
614
610
private double x ;
615
- /** the y part of the vector. ` */
611
+ /** The y part of the vector. ` */
616
612
private double y ;
617
- /** the z part of the vector. ` */
613
+ /** The z part of the vector. ` */
618
614
private double z ;
619
615
620
- /** default constructor. */
616
+ /** Default constructor. */
621
617
Vector4 () {
622
618
this .w = 0.0 ;
623
619
this .x = 0.0 ;
@@ -724,7 +720,7 @@ public Vector4 subtract(final Vector4 vector) {
724
720
this .z - vector .z );
725
721
}
726
722
727
- public static final Vector4 scalarMultiply (final Vector4 vector , final double multiplier ) {
723
+ public static Vector4 scalarMultiply (final Vector4 vector , final double multiplier ) {
728
724
729
725
return new Vector4 (
730
726
vector .w * Math .abs (multiplier ),
@@ -736,7 +732,7 @@ public static final Vector4 scalarMultiply(final Vector4 vector, final double mu
736
732
/**
737
733
* Calculates the angle between vectors v1 and v2.
738
734
*/
739
- public static final double angle (final Vector4 v1 , final Vector4 v2 ) {
735
+ public static double angle (final Vector4 v1 , final Vector4 v2 ) {
740
736
AbstractSatellite .magnitude (v1 );
741
737
AbstractSatellite .magnitude (v2 );
742
738
return Math .acos (AbstractSatellite .dot (v1 , v2 ) / (v1 .w * v2 .w ));
@@ -745,7 +741,7 @@ public static final double angle(final Vector4 v1, final Vector4 v2) {
745
741
/**
746
742
* Subtracts vector v2 from v1.
747
743
*/
748
- public static final Vector4 subtract (final Vector4 v1 , final Vector4 v2 ) {
744
+ public static Vector4 subtract (final Vector4 v1 , final Vector4 v2 ) {
749
745
750
746
final Vector4 v3 = new Vector4 ();
751
747
v3 .x = v1 .x - v2 .x ;
@@ -886,12 +882,7 @@ private boolean isEclipsed() {
886
882
final double delta = Vector4 .angle (sunVector , earth );
887
883
eclipseDepth = sdEarth - sdSun - delta ;
888
884
889
- if (sdEarth < sdSun ) {
890
- return false ;
891
- }
892
- else {
893
- return eclipseDepth >= 0 ;
894
- }
885
+ return sdEarth >= sdSun && eclipseDepth >= 0 ;
895
886
}
896
887
897
888
private Vector4 calculateSunVector () {
0 commit comments