public void ToCartesian() { Ellipsoid ellipsoid = new Ellipsoid(new Cartesian(1, 1, 0.7)); Assert.IsTrue(((Cartesian)UnitCartesian.UnitX).EqualsEpsilon(ellipsoid.ToCartesian(new Cartographic(0, 0, 0)), Constants.Epsilon10)); Assert.IsTrue(((Cartesian)UnitCartesian.UnitY).EqualsEpsilon(ellipsoid.ToCartesian(new Cartographic(Constants.HalfPi, 0, 0)), Constants.Epsilon10)); Assert.IsTrue(new Cartesian(0, 0, 0.7).EqualsEpsilon(ellipsoid.ToCartesian(new Cartographic(0, Constants.HalfPi, 0)), Constants.Epsilon10)); }
/// <summary> /// Initializes a new instance tangent to <paramref name="ellipsoid"/> at /// the center of a bounded set of <paramref name="positions"/>. /// </summary> /// <param name="ellipsoid">The ellipsoid .</param> /// <param name="positions"></param> public EllipsoidTangentPlane(Ellipsoid ellipsoid, IList<Cartesian> positions) { if (ellipsoid == null) { throw new ArgumentNullException("ellipsoid"); } if (positions == null) { throw new ArgumentNullException("positions"); } if (positions.Count < 1) { throw new ArgumentOutOfRangeException("positions", "At least one position is required."); } AxisAlignedBoundingBox box = new AxisAlignedBoundingBox(positions); _origin = ellipsoid.ScaleToGeodeticSurface(box.Center); _normal = ellipsoid.GeodeticSurfaceNormal(_origin); _d = -_origin.Dot(_origin); _yAxis = _origin.Cross(_origin.MostOrthogonalAxis).Normalize(); _xAxis = _yAxis.Cross(_origin).Normalize(); }
public void Construct() { Ellipsoid ellipsoid = new Ellipsoid(new Cartesian(1, 2, 3)); Assert.AreEqual(1, ellipsoid.Radii.X); Assert.AreEqual(2, ellipsoid.Radii.Y); Assert.AreEqual(3, ellipsoid.Radii.Z); Ellipsoid ellipsoid2 = new Ellipsoid(new Cartesian(4, 5, 6)); Assert.AreEqual(new Cartesian(4, 5, 6), ellipsoid2.Radii); Ellipsoid sphere = Ellipsoid.UnitSphere; Assert.IsTrue(sphere.RadiiSquared.Equals((new Cartesian(1, 1, 1)))); Assert.IsTrue(sphere.OneOverRadiiSquared.Equals((new Cartesian(1, 1, 1)))); }