public void TestEqualityWithWrongType()
        {
            Matrix3By3 first = Matrix3By3.Identity;
            Cartesian second = new Cartesian(1.0, 2.0, 3.0);

            Assert.IsFalse(first.Equals(second));
        }
Esempio n. 2
0
    public void initFieldsVal()
    {
        Cartesian Cell;
        this.PlayerField = new int[10, 10];

        //Initialize visible and collision matrix
        this.Vision = new BoolMatrix ();
        Vision.initMatrix (10, 10);

        BoolMatrix OccupPositions = new BoolMatrix ();
        OccupPositions.initMatrix (10, 10);

        for (int size=4; size>0; size--) {
            int num = 5 - size;
            for (int i=0; i<num; i++) {
                bool isPlaced = true;
                do {
                Cell = new Cartesian(Random.Range(0,10),Random.Range(0,10));
                if (OccupPositions.isFreeCell (Cell, size)) {
                        isPlaced = false;
                    }
                }while(isPlaced);
            }
        }
    }
        public void TestEqualityWithWrongType()
        {
            Cartographic first = new Cartographic(1.0, 2.0, 3.0);
            Cartesian second = new Cartesian(1.0, 2.0, 3.0);

            Assert.IsFalse(first.Equals(second));
        }
Esempio n. 4
0
    private bool[,] SelectArea(Cartesian areaB, Cartesian areaE)
    {
        int cX, cY;
        cX = areaB.X;
        cY = areaB.Y;

        //Debug info
        //Debug.Log("Begin coordinates - ("+ cX+","+cY+")");

        int colNum = areaE.X - areaB.X+1;
        int strNum = areaE.Y - areaB.Y+1;

        //Debug info
        //Debug.Log("Selected Area - ("+ strNum+"x"+colNum+")");

        bool[,] findedCells = new bool[strNum,colNum];
        for(int i = 0; i<strNum; i++){
            if(i!=0) cY++;
            cX=areaB.X;
            for(int j=0; j<colNum; j++){
                if(j!=0) cX++;
                findedCells[i,j] = this.logicMatrix[cX,cY];

                //Debug info
                //Debug.Log("Readed from Matrix("+ cX+","+cY+")");
            }
        }
        return findedCells;
    }
Esempio n. 5
0
 public void TestHoldValue()
 {
     Cartesian test = new Cartesian(1.0, 2.0, 3.0);
     Assert.AreEqual(1.0, test.X);
     Assert.AreEqual(2.0, test.Y);
     Assert.AreEqual(3.0, test.Z);
 }
        public void TestCrossProduct()
        {
            double angle = Math.PI / 4.0;
            double cos = Math.Cos(angle / 2.0);
            double sin = Math.Sin(angle / 2.0);

            double a = cos * cos - sin * sin / 3.0;
            double b = 2.0 * (sin * sin + sin * cos * Math.Sqrt(3.0)) / 3.0;
            double c = 2.0 * (sin * sin - sin * cos * Math.Sqrt(3.0)) / 3.0;

            // The three vectors here are the orthonormal set obtained by rotating
            // the x-axis, y-axis, and z-axis through an angle of 45 degrees about
            // the (1,1,1) vector.
            UnitCartesian first = new UnitCartesian(a, b, c);
            UnitCartesian second = new UnitCartesian(c, a, b);
            UnitCartesian third = new UnitCartesian(b, c, a);
            Cartesian result = first.Cross(second);

            Assert.AreEqual(third.X, result.X, Constants.Epsilon14);
            Assert.AreEqual(third.Y, result.Y, Constants.Epsilon14);
            Assert.AreEqual(third.Z, result.Z, Constants.Epsilon14);

            Cartesian Cartesian3 = new Cartesian(c, a, b);
            result = first.Cross(Cartesian3);

            Assert.AreEqual(third.X, result.X, Constants.Epsilon14);
            Assert.AreEqual(third.Y, result.Y, Constants.Epsilon14);
            Assert.AreEqual(third.Z, result.Z, Constants.Epsilon14);
        }
Esempio n. 7
0
        public static bool TryIntersectRayPlane(
            Cartesian rayOrigin,
            Cartesian rayDirection,
            Cartesian planeNormal,
            double planeD,
            out Cartesian intersectionPoint)
        {
            double denominator = planeNormal.Dot(rayDirection);

            if (Math.Abs(denominator) < 0.00000000000000000001)
            {
                // Ray is parallel to plane.  The ray may be in the polygon's plane.
                intersectionPoint = Cartesian.Zero;
                return false;
            }

            double t = (-planeD - planeNormal.Dot(rayOrigin)) / denominator;

            if (t < 0)
            {
                intersectionPoint = Cartesian.Zero;
                return false;
            }

            intersectionPoint = rayOrigin + (t * rayDirection);
            return true;
        }
Esempio n. 8
0
 public bool isEmptyCell(Cartesian C)
 {
     if(!this.logicMatrix[C.X,C.Y]){
         return true;
     }
     return false;
 }
Esempio n. 9
0
        public void TestFromArray()
        {
            double[] values = { 2.0, 3.0, 6.0 };

            Cartesian test = new Cartesian(values);
            Assert.AreEqual(values.Length, test.Length);
            Assert.AreEqual(test.X, test[0]);
            Assert.AreEqual(test.Y, test[1]);
            Assert.AreEqual(test.Z, test[2]);
        }
Esempio n. 10
0
        /// <summary>
        /// Scales a <see cref="Cartesian"/> point to the surface of the ellipsoid along the geodetic surface normal.
        /// </summary>
        /// <param name="position">The point to scale.</param>
        /// <returns>The position of the point on the ellipsoid's surface.</returns>
        public Cartesian ScaleToGeodeticSurface(Cartesian position)
        {
            double beta = 1.0 / Math.Sqrt(
                (position.X * position.X) * _oneOverRadiiSquared.X +
                (position.Y * position.Y) * _oneOverRadiiSquared.Y +
                (position.Z * position.Z) * _oneOverRadiiSquared.Z);
            double n = new Cartesian(
                beta * position.X * _oneOverRadiiSquared.X,
                beta * position.Y * _oneOverRadiiSquared.Y,
                beta * position.Z * _oneOverRadiiSquared.Z).Magnitude;
            double alpha = (1.0 - beta) * (position.Magnitude / n);

            double x2 = position.X * position.X;
            double y2 = position.Y * position.Y;
            double z2 = position.Z * position.Z;

            double da = 0.0;
            double db = 0.0;
            double dc = 0.0;

            double s = 0.0;
            double dSdA = 1.0;

            do
            {
                alpha -= (s / dSdA);

                da = 1.0 + (alpha * _oneOverRadiiSquared.X);
                db = 1.0 + (alpha * _oneOverRadiiSquared.Y);
                dc = 1.0 + (alpha * _oneOverRadiiSquared.Z);

                double da2 = da * da;
                double db2 = db * db;
                double dc2 = dc * dc;

                double da3 = da * da2;
                double db3 = db * db2;
                double dc3 = dc * dc2;

                s = x2 / (_radiiSquared.X * da2) +
                    y2 / (_radiiSquared.Y * db2) +
                    z2 / (_radiiSquared.Z * dc2) - 1.0;

                dSdA = -2.0 *
                    (x2 / (_radiiToTheFourth.X * da3) +
                     y2 / (_radiiToTheFourth.Y * db3) +
                     z2 / (_radiiToTheFourth.Z * dc3));
            }
            while (Math.Abs(s) > 1e-10);

            return new Cartesian(
                position.X / da,
                position.Y / db,
                position.Z / dc);
        }
        public void TestAdd()
        {
            Cartesian original = new Cartesian(10.0, 20.0, 30.0);
            Cartesian toAdd = new Cartesian(1.0, 2.0, 3.0);
            Cartesian result = original + toAdd;
            Assert.AreEqual(11.0, result.X);
            Assert.AreEqual(22.0, result.Y);
            Assert.AreEqual(33.0, result.Z);

            result = original.Add(toAdd);
            Assert.AreEqual(11.0, result.X);
            Assert.AreEqual(22.0, result.Y);
            Assert.AreEqual(33.0, result.Z);
        }
        public void Simple()
        {
            Cartesian min = new Cartesian(-1, -1, -1);
            Cartesian max = new Cartesian(1, 1, 1);

            IList<Cartesian> positions = new List<Cartesian>();
            positions.Add(min);
            positions.Add(max);

            AxisAlignedBoundingBox box = new AxisAlignedBoundingBox(positions);
            Assert.AreEqual(min, box.Minimum);
            Assert.AreEqual(max, box.Maximum);
            Assert.AreEqual(Cartesian.Zero, box.Center);
        }
Esempio n. 13
0
        public EntityPlatform(ExampleEntity entity, EarthCentralBody earth, string dataPath)
        {
            //id, string
            m_id = entity.EntityIdentifier.ToString();

            //name, string
            string name = entity.Marking.ToString();

            //Last Update, DateTime
            DateTime time = DateTime.Parse(entity.LastUpdateDateTime.ToString());

            //Position, Cartesian
            string[] xyz = entity.Position.ToString().Split(',');
            Cartesian position = new Cartesian(Convert.ToDouble(xyz[0]), Convert.ToDouble(xyz[1]), Convert.ToDouble(xyz[2]));

            m_platform = new Platform();
            m_platform.Name = name;
            m_platform.LocationPoint = new PointCartographic(earth, earth.Shape.CartesianToCartographic(position));
            m_platform.OrientationAxes = new AxesVehicleVelocityLocalHorizontal(earth.FixedFrame, m_platform.LocationPoint);

            LabelGraphicsExtension labelExtension = new LabelGraphicsExtension(new LabelGraphics
            {
                Text = new ConstantCesiumProperty<string>(name),
                Scale = new ConstantCesiumProperty<double>(0.5),
                FillColor = new ConstantCesiumProperty<Color>(Color.White),
                PixelOffset = new ConstantCesiumProperty<Rectangular>(new Rectangular(35, -15))
            });
            m_platform.Extensions.Add(labelExtension);

            string symbol = entity.Symbology.ToString().Replace('*', '_') + ".png";
            CesiumResource billboardResource = new CesiumResource(new Uri(dataPath + symbol), CesiumResourceBehavior.LinkTo);
            BillboardGraphicsExtension billboardExtension = new BillboardGraphicsExtension(new BillboardGraphics
            {
                Image = new ConstantCesiumProperty<CesiumResource>(billboardResource),
                Show = true,
                Scale = new ConstantCesiumProperty<double>(1)
            });
            m_platform.Extensions.Add(billboardExtension);

            m_czmlDocument = new CzmlDocument();
            m_czmlDocument.Name = "Realtime";
            m_czmlDocument.RequestedInterval = new TimeInterval(new JulianDate(DateTime.Now), new JulianDate(DateTime.Now.AddDays(1.0)));
            m_czmlDocument.Clock = new Clock
            {
                Step = ClockStep.SystemClock
            };

            m_czmlDocument.ObjectsToWrite.Add(m_platform);
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance with specific radii.
 /// </summary>
 /// <param name="radii">The ellipsoid's radius in the x, y, and z directions</param>
 public Ellipsoid(Cartesian radii)
 {
     _radii = radii;
     _radiiSquared = new Cartesian(
         radii.X * radii.X,
         radii.Y * radii.Y,
         radii.Z * radii.Z);
     _radiiToTheFourth = new Cartesian(
         _radiiSquared.X * _radiiSquared.X,
         _radiiSquared.Y * _radiiSquared.Y,
         _radiiSquared.Z * _radiiSquared.Z);
     _oneOverRadiiSquared = new Cartesian(
         1.0 / (radii.X * radii.X),
         1.0 / (radii.Y * radii.Y),
         1.0 / (radii.Z * radii.Z));
 }
Esempio n. 15
0
        public void TestIsPointInTriangle()
        {
            Cartesian a = new Cartesian(0, 0, 0);
            Cartesian b = new Cartesian(0, 1, 0);
            Cartesian c = new Cartesian(1, 0, 0);

            // p is on the boundary of the triangle
            Cartesian p = new Cartesian(0, 0, 0);
            Assert.That(PolygonAlgorithms.IsPointInTriangle(a, b, c, p));

            // p is inside the triangle
            p = new Cartesian(0.5, 0.25, 0);
            Assert.That(PolygonAlgorithms.IsPointInTriangle(a, b, c, p));

            // p is outside the triangle
            p = new Cartesian(1, 1, 0);
            Assert.That(PolygonAlgorithms.IsPointInTriangle(a, b, c, p) == false);
        }
Esempio n. 16
0
        /// <summary>
        /// Determines if a given point lies inside or on the boundary of the triangle formed by three points.
        /// </summary>
        /// <param name="a">The first vertex of the triangle.</param>
        /// <param name="b">The second vertex of the triangle.</param>
        /// <param name="c">The third vertex of the triangle.</param>
        /// <param name="point">The point to test.</param>
        /// <returns>True if the point lies within the triangle formed by a, b, and c, false otherwise.</returns>
        public static bool IsPointInTriangle(Cartesian a, Cartesian b, Cartesian c, Cartesian point)
        {
            Cartesian v0 = c - a;
            Cartesian v1 = b - a;
            Cartesian v2 = point - a;

            double dot00 = v0.Dot(v0);
            double dot01 = v0.Dot(v1);
            double dot02 = v0.Dot(v2);
            double dot11 = v1.Dot(v1);
            double dot12 = v1.Dot(v2);

            double inverseDenominator = 1.0 / (dot00 * dot11 - dot01 * dot01);
            double u = (dot11 * dot02 - dot01 * dot12) * inverseDenominator;
            double v = (dot00 * dot12 - dot01 * dot02) * inverseDenominator;

            return (u >= 0) && (v >= 0) && (u + v < 1);
        }
Esempio n. 17
0
        public void TestEquality()
        {
            Cartesian first = new Cartesian(1.0, 2.0, 3.0);
            Cartesian second = new Cartesian(1.0, 2.0, 3.0);
            Assert.AreEqual(first, second);
            Assert.AreEqual(second, first);
            Assert.IsTrue(first == second);
            Assert.IsTrue(second == first);
            Assert.IsFalse(first != second);
            Assert.IsFalse(second != first);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));

            second = new Cartesian(0.0, 2.0, 3.0);
            Assert.AreNotEqual(first, second);
            Assert.AreNotEqual(second, first);
            Assert.IsFalse(first == second);
            Assert.IsFalse(second == first);
            Assert.IsTrue(first != second);
            Assert.IsTrue(second != first);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));

            second = new Cartesian(1.0, 0.0, 3.0);
            Assert.AreNotEqual(first, second);
            Assert.AreNotEqual(second, first);
            Assert.IsFalse(first == second);
            Assert.IsFalse(second == first);
            Assert.IsTrue(first != second);
            Assert.IsTrue(second != first);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));

            second = new Cartesian(1.0, 2.0, 0.0);
            Assert.AreNotEqual(first, second);
            Assert.AreNotEqual(second, first);
            Assert.IsFalse(first == second);
            Assert.IsFalse(second == first);
            Assert.IsTrue(first != second);
            Assert.IsTrue(second != first);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
        }
Esempio n. 18
0
    //Cell and area around
    public bool isFreeCell(Cartesian C, int size)
    {
        int dir;
        Cartesian beg, end,send;
        bool[,] tempColl;
        if(!this.logicMatrix[C.X,C.Y]){

            //Check spare place for ship
            //Attention! Magic number further (9 - maximum matrix index)
            if((9-C.X)<size &&(9-C.Y)<size) return false;
            else if((9-C.X)<size) dir = 0;
            else if((9-C.Y)<size) dir = 1;
            else dir = Random.Range(0,2);

            //Debug info
            //Debug.Log(size+"ship attemps, coord - ("+ C.X+","+C.Y+") in dir "+ dir);

            // Transform origin ship coord into ship extreme positions;
            beg = new Cartesian(C.X-1,C.Y-1);

            if(dir == 0) {end = new Cartesian(C.X+1,C.Y+size);
                send = new Cartesian(C.X, C.Y+size);
            }
            else {end = new Cartesian(C.X+size,C.Y+1);
                send = new Cartesian(C.X+size, C.Y);
            }

            // Prevent contact collisions
            tempColl = this.SelectArea(beg,end);

            for(int i=0; i<tempColl.GetLength(0);i++){
                for(int j=0; j<tempColl.GetLength(1);j++){
                    if(tempColl[i,j]) return false;
                }
            }
            this.SetArea(C,send);
            Debug.Log(size+"ship placed, coord - ("+ C.X+","+C.Y+") in dir" + dir);
            return true;
        }
        else return false;
    }
        public void TestAdd()
        {
            UnitCartesian original1 = UnitCartesian.UnitX;
            UnitCartesian toAdd1 = UnitCartesian.UnitY;
            Cartesian result = original1 + toAdd1;
            Assert.AreEqual(1.0, result.X);
            Assert.AreEqual(1.0, result.Y);
            Assert.AreEqual(0.0, result.Z);

            Cartesian toAdd2 = new Cartesian(0.0, 1.0, 1.0);
            result = original1 + toAdd2;
            Assert.AreEqual(1.0, result.X);
            Assert.AreEqual(1.0, result.Y);
            Assert.AreEqual(1.0, result.Z);

            Cartesian original2 = new Cartesian(0.0, 1.0, 1.0);
            UnitCartesian toAdd3 = UnitCartesian.UnitX;
            result = original2 + toAdd3;
            Assert.AreEqual(1.0, result.X);
            Assert.AreEqual(1.0, result.Y);
            Assert.AreEqual(1.0, result.Z);
        }
Esempio n. 20
0
 /// <summary>
 /// Writes a value for the <code>position</code> property as a <code>cartesian</code> value.  The <code>position</code> property specifies the position of the object in the world. The position has no direct visual representation, but it is used to locate billboards, labels, and other primitives attached to the object.
 /// </summary>
 /// <param name="value">The value.</param>
 public void WritePositionProperty(Cartesian value)
 {
     using (var writer = OpenPositionProperty())
     {
         writer.WriteCartesian(value);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Writes a <see cref="Cartesian"/> value as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian3(CesiumOutputStream output, Cartesian value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteValue(value.Z);
     output.WriteEndSequence();
 }
        /// <summary>
        /// Creates an instance of an AxisAlignedBoundingBox.
        /// </summary>
        /// <param name="positions">The <see cref="Cartesian"/> points to be contained within the bounding box.</param>
        public AxisAlignedBoundingBox(IEnumerable<Cartesian> positions)
        {
            if (positions == null)
            {
                throw new ArgumentNullException("positions");
            }

            double minimumX = double.MaxValue;
            double minimumY = double.MaxValue;
            double minimumZ = double.MaxValue;

            double maximumX = -double.MaxValue;
            double maximumY = -double.MaxValue;
            double maximumZ = -double.MaxValue;

            foreach (Cartesian position in positions)
            {
                if (position.X < minimumX)
                {
                    minimumX = position.X;
                }

                if (position.X > maximumX)
                {
                    maximumX = position.X;
                }

                if (position.Y < minimumY)
                {
                    minimumY = position.Y;
                }

                if (position.Y > maximumY)
                {
                    maximumY = position.Y;
                }

                if (position.Z < minimumZ)
                {
                    minimumZ = position.Z;
                }

                if (position.Z > maximumZ)
                {
                    maximumZ = position.Z;
                }
            }

            Cartesian minimum = new Cartesian(minimumX, minimumY, minimumZ);
            Cartesian maximum = new Cartesian(maximumX, maximumY, maximumZ);

            if (minimum.AllComponentsAreGreaterThan(maximum))
            {
                Cartesian temp = minimum;
                minimum = maximum;
                maximum = temp;
            }

            _minimum = minimum;
            _maximum = maximum;
        }
Esempio n. 23
0
        private void _TestFromMatrix3By3(double angle, Cartesian axis)
        {
            Cartesian unit = axis.Normalize();

            double c = Math.Cos(angle);
            double s = Math.Sin(angle);

            double w = c;
            double x = s * unit.X;
            double y = s * unit.Y;
            double z = s * unit.Z;

            UnitQuaternion quaternion = new UnitQuaternion(w, x, y, z);
            Matrix3By3 matrix = new Matrix3By3(quaternion);

            UnitQuaternion test = new UnitQuaternion(matrix);

            Assert.AreEqual(w, quaternion.W, Constants.Epsilon15);
            Assert.AreEqual(x, quaternion.X, Constants.Epsilon15);
            Assert.AreEqual(y, quaternion.Y, Constants.Epsilon15);
            Assert.AreEqual(z, quaternion.Z, Constants.Epsilon15);
        }
Esempio n. 24
0
        /***************************************************/

        private static List <ICurve> Arrows(Point pt, Vector load, bool straightArrow, bool asResultant, Cartesian coordinateSystem = null, int nbArrowHeads = 1)
        {
            Point[] basePoints;
            return(Arrows(pt, load, straightArrow, asResultant, out basePoints, coordinateSystem, nbArrowHeads));
        }
Esempio n. 25
0
 public void TestToString()
 {
     double val1 = 1.1;
     double val2 = 2.1;
     double val3 = 3.1;
     string sep = ", ";
     String result = val1.ToString(CultureInfo.CurrentCulture) + sep + val2.ToString(CultureInfo.CurrentCulture) + sep +
                     val3.ToString(CultureInfo.CurrentCulture);
     Cartesian test = new Cartesian(val1, val2, val3);
     Assert.AreEqual(result, test.ToString());
 }
Esempio n. 26
0
 public void TestIndexTooHigh()
 {
     Cartesian first = new Cartesian(1.0, 2.0, 3.0);
     double bad = first[3];
 }
Esempio n. 27
0
 public void TestInitializationFromBadArray()
 {
     double[] array = new double[2];
     Cartesian first = new Cartesian(array, 0);
 }
Esempio n. 28
0
 public void TestInitializationFromNull()
 {
     double[] array = null;
     Cartesian first = new Cartesian(array, 0);
 }
Esempio n. 29
0
 public void TestGetHashCode()
 {
     Cartesian object1 = new Cartesian(1.0, 2.0, 3.0);
     Cartesian object2 = new Cartesian(1.0, 2.0, 3.0);
     Cartesian object3 = new Cartesian(1.0, 2.0, 3.1);
     Assert.AreEqual(object1.GetHashCode(), object2.GetHashCode());
     Assert.AreNotEqual(object1.GetHashCode(), object3.GetHashCode());
 }
Esempio n. 30
0
        /***************************************************/

        private static List <ICurve> Arrows(Point pt, Vector load, bool straightArrow, bool asResultant, out Point[] basePoints, Cartesian coordinateSystem = null, int nbArrowHeads = 1)
        {
            if (asResultant)
            {
                Vector vector;
                if (coordinateSystem == null)
                {
                    vector = load;
                }
                else
                {
                    vector = coordinateSystem.X * load.X + coordinateSystem.Y * load.Y + coordinateSystem.Z * load.Z;
                }

                basePoints = new Point[1];
                if (straightArrow)
                {
                    return(Arrow(pt, vector, out basePoints[0], nbArrowHeads));
                }
                else
                {
                    return(ArcArrow(pt, vector, out basePoints[0]));
                }
            }
            else
            {
                List <ICurve> arrows = new List <ICurve>();
                basePoints = new Point[3];
                Vector[] vectors;

                if (coordinateSystem == null)
                {
                    vectors = new Vector[] { new Vector {
                                                 X = load.X
                                             }, new Vector {
                                                 Y = load.Y
                                             }, new Vector {
                                                 Z = load.Z
                                             } }
                }
                ;
                else
                {
                    vectors = new Vector[] { coordinateSystem.X *load.X, coordinateSystem.Y *load.Y, coordinateSystem.Z *load.Z }
                };

                for (int i = 0; i < 3; i++)
                {
                    if (straightArrow)
                    {
                        arrows.AddRange(Arrow(pt, vectors[i], out basePoints[i], nbArrowHeads, 0.02));
                    }
                    else
                    {
                        arrows.AddRange(ArcArrow(pt, vectors[i], out basePoints[i]));
                    }
                }
                return(arrows);
            }
        }
Esempio n. 31
0
 /// <summary>
 /// Writes the <code>viewFrom</code> property.  The <code>viewFrom</code> property specifies a suggested camera location when viewing this object.  The property is specified as a Cartesian position in the East (x), North (y), Up (z) reference frame relative to the objects position property.
 /// </summary>
 /// <param name="value">The value.</param>
 public void WriteViewFrom(Cartesian value)
 {
     const string PropertyName = ViewFromPropertyName;
     Output.WritePropertyName(PropertyName);
     CesiumWritingHelper.WriteCartesian3(Output, value);
 }
Esempio n. 32
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static Vector[] BarForceVectors(Bar bar, Vector globalForce, Vector globalMoment, LoadAxis axis, bool isProjected, out Cartesian system)
        {
            if (axis == LoadAxis.Global)
            {
                system = null;
                if (isProjected)
                {
                    Point  startPos = bar.StartNode.Position();
                    Vector tan      = bar.Tangent();

                    Vector tanUnit    = tan.Normalise();
                    Vector forceUnit  = globalForce.Normalise();
                    Vector momentUnit = globalMoment.Normalise();

                    double scaleFactorForce  = (tanUnit - tanUnit.DotProduct(forceUnit) * forceUnit).Length();
                    double scaleFactorMoment = (tanUnit - tanUnit.DotProduct(momentUnit) * momentUnit).Length();

                    return(new Vector[] { globalForce *scaleFactorForce, globalMoment *scaleFactorMoment });
                }
                else
                {
                    return(new Vector[] { globalForce, globalMoment });
                }
            }
            else
            {
                Vector normal  = bar.Normal();
                Vector tan     = bar.Tangent();
                Vector tanUnit = tan.Normalise();
                Vector y       = normal.CrossProduct(tanUnit);

                system = new Cartesian(new Point(), tanUnit, y, normal);

                return(new Vector[] { globalForce, globalMoment });
            }
        }
Esempio n. 33
0
 public void TestMathOperatorsWithCartesian()
 {
     Matrix3By3 test = new Matrix3By3(1.0, 2.0, 4.0, 2.0, 3.0, 5.0, 4.0, 5.0, 6.0);
     Cartesian mult = new Cartesian(1, 2, 3);
     Assert.IsTrue((new Cartesian(17, 23, 32).Equals(test.Multiply(mult))));
     Assert.IsTrue((new Cartesian(17, 23, 32).Equals(test * mult)));
 }
Esempio n. 34
0
        /***************************************************/

        public static Cartesian Translate(this Cartesian coordinateSystem, Vector transform)
        {
            return(new Cartesian(coordinateSystem.Origin + transform, coordinateSystem.X, coordinateSystem.Y, coordinateSystem.Z));
        }