Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal void CreatePointArray()
- {
- Vector4 vel = Distance.KmToAU(_newtonMoveDB.CurrentVector_kms);
- Vector4 pos = myPosDB.RelativePosition_AU;
- Vector4 eccentVector = OrbitMath.EccentricityVector(_sgp, pos, vel);
- double e = eccentVector.Length();
- double r = pos.Length();
- double v = vel.Length();
- double a = 1 / (2 / r - Math.Pow(v, 2) / _sgp); //semiMajor Axis
- double b = -a * Math.Sqrt(Math.Pow(e, 2) - 1); //semiMinor Axis
- double linierEccentricity = e * a;
- double soi = OrbitProcessor.GetSOI(_newtonMoveDB.SOIParent);
- //longditudeOfPeriapsis;
- double _lop = Math.Atan2(eccentVector.Y, eccentVector.X);
- if (Vector4.Cross(pos, vel).Z < 0) //anti clockwise orbit
- _lop = Math.PI * 2 - _lop;
- double p = EllipseMath.SemiLatusRectum(a, e);
- double angleToSOIPoint = Math.Abs(OrbitMath.AngleAtRadus(soi, p, e));
- double thetaMax = angleToSOIPoint;
- if (_numberOfPoints % 2 == 0)
- _numberOfPoints += 1;
- int ctrIndex = _numberOfPoints / 2;
- double dtheta = thetaMax / (ctrIndex -1);
- double fooA = Math.Cosh(dtheta);
- double fooB = (a / b) * Math.Sinh(dtheta);
- double fooC = (b / a) * Math.Sinh(dtheta);
- double xn = a;
- double yn = 0;
- var points = new PointD[ctrIndex + 1];
- points[0] = new PointD() { X = xn, Y = yn };
- for (int i = 1; i < ctrIndex + 1; i++)
- {
- var lastx = xn;
- var lasty = yn;
- xn = fooA * lastx + fooB * lasty;
- yn = fooC * lastx + fooA * lasty;
- points[i] = new PointD() { X = xn, Y = yn };
- }
- _points = new PointD[_numberOfPoints];
- _points[ctrIndex] = new PointD()
- {
- X = ((points[0].X - linierEccentricity )* Math.Cos(_lop)) - (points[0].Y * Math.Sin(_lop)),
- Y = ((points[0].X - linierEccentricity) * Math.Sin(_lop)) + (points[0].Y * Math.Cos(_lop))
- };
- for (int i = 1; i < ctrIndex + 1; i++)
- {
- double x = points[i].X - linierEccentricity; //adjust for the focal point
- double ya = points[i].Y;
- double yb = -points[i].Y;
- double x2a = (x * Math.Cos(_lop)) - (ya * Math.Sin(_lop)); //rotate to loan
- double y2a = (x * Math.Sin(_lop)) + (ya * Math.Cos(_lop));
- double x2b = (x * Math.Cos(_lop)) - (yb * Math.Sin(_lop));
- double y2b = (x * Math.Sin(_lop)) + (yb * Math.Cos(_lop));
- _points[ctrIndex + i] = new PointD()
- {
- X = x2a,
- Y = y2a
- };
- _points[ctrIndex - i] = new PointD()
- {
- X = x2b,
- Y = y2b
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement