コード例 #1
0
ファイル: CadViewPort.cs プロジェクト: catashd/NetVecCad
 public CadViewPort(String name, Model parentMdl,
  Point center, Double height, Double width,
  Vector scaleVec,
  Angle rotation)
     : this(name, parentMdl, center, new Vector(width, height, null), scaleVec, rotation)
 {
 }
コード例 #2
0
ファイル: CadViewPort.cs プロジェクト: catashd/NetVecCad
 public CadViewPort(String name, CadViewPort other)
     : this(name, other.parentModel)
 {
     Height = other.Height; Width = other.Width;
      Origin = new Point(other.Origin);
      ScaleVector = new Vector(other.ScaleVector.x, other.ScaleVector.y, other.ScaleVector.z);
      Rotation = new Angle(other.Rotation.angle_);
 }
コード例 #3
0
ファイル: CadViewPort.cs プロジェクト: catashd/NetVecCad
 public CadViewPort(String name, Model parentMdl)
 {
     this.parentModel = parentMdl;
      Name = name;
      ViewAspect = new Vector(3, 3, null);
      Origin = new Point(0,0);
      ScaleVector = new Vector(1.0, 1.0, 1.0);
      Rotation = new Angle(0);
      updateBoundingBox();
 }
コード例 #4
0
ファイル: CadViewPort.cs プロジェクト: catashd/NetVecCad
 public CadViewPort(String name, Model parentMdl,
  Point center, Vector aspectVec,
  Vector scaleVec,
  Angle rotation)
     : this(name, parentMdl)
 {
     Origin = center;
      ViewAspect = aspectVec;
      ScaleVector = scaleVec;
      Rotation = rotation;
 }
コード例 #5
0
ファイル: Arc.cs プロジェクト: catashd/NetVecCad
 public Arc(Point centerPt, Double incomingDir_, Double outgoingDir_, Double radius)
 {
     Azimuth incomingDir = Azimuth.ctorAzimuthFromDegree(incomingDir_);
      Azimuth outgoingDir = Azimuth.ctorAzimuthFromDegree(outgoingDir_);
      int modifier = (outgoingDir - incomingDir) > 0 ? 1 : -1;
      Azimuth BegRadiusDirection = incomingDir +
     new Deflection(Math.PI / 2.0, -1 * modifier);
      BeginRadiusVector = new Vector(
     direction: BegRadiusDirection,
     length: radius);
      Point startPt = centerPt + BeginRadiusVector;
      Deflection def = outgoingDir - incomingDir;
      populateThis(startPt, incomingDir, def, radius);
 }
コード例 #6
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
        public static void AreEqual(Vector expected, Vector actual)
        {
            Assert.AreEqual(expected: expected.x, actual: actual.x, delta: 0.0001);
             Assert.AreEqual(expected: expected.y, actual: actual.y, delta: 0.0001);

             if (expected.z != null)
             {
            if (actual.z != null)
            {
               Assert.AreEqual(
                  expected: (Double)expected.z,
                  actual: (Double)actual.z,
                  delta: 0.0001);
            }
            else
            {
               Assert.Fail("One of two Nullable Doubles is null.");
            }
             }
             else if (actual.z != null)
             {
            Assert.Fail("One of two Nullable Doubles is null.");
             }
        }
コード例 #7
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
        public void Point2D_plusVector_equalsCorrectPoint()
        {
            Point pt1 = new Point(10.0, 10.0);
             Vector vec1 = new Vector(5.0, 5.0, 5.0);

             Point pt2 = pt1 + vec1;

             Double expectedX = 15.0; Double expectedY = 15.0;

             Assert.AreEqual(expected: expectedX, actual: pt2.x, delta: 0.00001);
             Assert.AreEqual(expected: expectedY, actual: pt2.y, delta: 0.00001);
        }
コード例 #8
0
ファイル: Arc.cs プロジェクト: catashd/NetVecCad
        private void populateThis(Point StartPoint, Azimuth incomingDir, Deflection defl,
         Double radius)
        {
            Origin = StartPoint;
             Rotation = incomingDir;
             Deflection = defl;

             Azimuth BegRadiusDirection = incomingDir +
            new Deflection(Math.PI / 2.0, -1 * Deflection.deflectionDirection);

             BeginRadiusVector = new Vector(
            direction: BegRadiusDirection,
            length: radius);
             CenterPt = StartPoint - BeginRadiusVector;
             EndRadiusVector = BeginRadiusVector + Deflection;

             // Conic Section components
             Eccentricity = 0.0;
             a = b = Radius = BeginRadiusVector.Length;

             // Path Components
             StartPt = StartPoint;
             EndPt = CenterPt + EndRadiusVector;
             StartAzimuth = incomingDir;
             EndAzimuth = StartAzimuth + Deflection;
             Length = (Deflection.angle_ / Math.PI) * Radius;

             // Graphic Components not already set
             ScaleVector = new Vector(Azimuth.ctorAzimuthFromDegree(45.0), Radius);

             computeBoundingBox();
        }
コード例 #9
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public Object Clone()
 {
     Vector clone = new Vector();
      clone.x = this.x; clone.y = this.y; clone.z = this.z;
      return clone;
 }
コード例 #10
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
        public void Arc_CreateArc_ctor3DeflectingLeft90_IsCorrect()
        {
            var anArc = new Arc(new Point(100.0, 100.0),
            Azimuth.ctorAzimuthFromDegree(90),
            Deflection.ctorDeflectionFromAngle(90.0, -1), 50.0);
             Assert.IsNotNull(anArc);

             Assert.AreEqual(
            expected: 180.0,
            actual: anArc.BeginRadiusVector.Azimuth.getAsDegreesDouble(),
            delta: 0.00001, message: "BeginRadiusVector");
             Assert.AreEqual(
            expected: 90.0,
            actual: anArc.StartAzimuth.getAsDegreesDouble(),
            delta: 0.00001, message: "BeginPointAngle");
             Assert.IsNotNull(anArc.BoundingBox);
             Assertt.AreEqual(
            expected: new Point(100,150),
            actual: anArc.CenterPt);
             Assert.AreEqual(
            expected: -90.0,
            actual: anArc.Deflection.getAsDegreesDouble(),
            delta: 0.00001, message: "Deflection");
             Assert.AreEqual(
            expected: 0.0,
            actual: anArc.Eccentricity,
            delta: 0.00001, message: "Eccentricity");
             Assertt.AreEqual(
            expected: new Point(150.0, 150.0),
            actual: anArc.EndPt);
             var expecVec = new Vector(Azimuth.ctorAzimuthFromDegree(90.0),
            50.0);
             Assertt.AreEqual(
            expected: expecVec,
            actual: anArc.EndRadiusVector);
             Assertt.AreEqual(
            expected: new Point(100.0, 100.0),
            actual: anArc.Origin);
             Assert.AreEqual(
            expected: 50.0,
            actual: anArc.Radius,
            delta: 0.00001, message: "Radius");
             Assert.AreEqual(
            expected: 0.0,
            actual: anArc.Rotation.getAsDegreesDouble(),
            delta: 0.00001, message: "Rotation");
             Assert.AreEqual(
            expected: 50.0,
            actual: anArc.ScaleVector.Length,
            delta: 0.00001);
        }
コード例 #11
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public double dotProduct(Vector otherVec)
 {
     return (this.x * otherVec.x) + (this.y * otherVec.y) + (this.z.Value * otherVec.z.Value);
 }
コード例 #12
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public Vector(Vector other)
     : this()
 {
     x = other.x; y = other.y; z = other.z;
 }
コード例 #13
0
ファイル: CadViewPort.cs プロジェクト: catashd/NetVecCad
        internal void FitView()
        {
            Vector screenSizeVec = new Vector();
             screenSizeVec.x = pairedUIview.getWidth() / 96;
             screenSizeVec.y = pairedUIview.getHeight() / 96;

             Vector possibleScales = new Vector();
             Vector parentBBvec = this.parentModel.getBoundingBox().getAsVectorLLtoUR();
             possibleScales.x = parentBBvec.x / screenSizeVec.x;
             possibleScales.y = parentBBvec.y / screenSizeVec.y;

             Double scaleToUse = possibleScales.getAbsMax();

             Double verticalExaggeration = this.ScaleVector.y /
            this.ScaleVector.x;
             this.ScaleVector.x = scaleToUse;
             this.ScaleVector.y = this.ScaleVector.x * verticalExaggeration;
             //this.scale_.z = screenVec.x;

             this.Origin = this.parentModel.getBoundingBox().getCenterPoint();
             pairedUIview.ViewGeometryChanged();
        }
コード例 #14
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public Vector rotateCloneAboutZ(Angle rotation)
 {
     var newVec = new Vector(this); //(Vector) this.Clone();
      newVec.rotateAboutZ(rotation);
      return newVec;
 }
コード例 #15
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public Double getScaleToMatch_maximized(Vector other)
 {
     return
     (this.getScaleToMatch(other)).getAbsMax();
 }
コード例 #16
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
        public Vector getScaleToMatch(Vector other)
        {
            Vector retVec = new Vector();
             retVec.x = other.x / this.x;
             retVec.y = other.y / this.y;
             retVec.z = other.z / this.z;

             return retVec;
        }
コード例 #17
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
 public void Vector_newVector_isCorrect()
 {
     var az = Azimuth.ctorAzimuthFromDegree(90.0);
      var aVec = new Vector(az,
     50.0);
      Assert.IsNotNull(aVec);
      Assert.AreEqual(expected: 50.0,
     actual: aVec.x, delta: 0.00001);
 }
コード例 #18
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
        public static Vector operator +(Vector vec1, Deflection defl)
        {
            Azimuth newAz = vec1.Azimuth + defl;
             Vector newVec = new Vector(newAz, vec1.Length);
             newVec.z = vec1.z;

             return newVec;
        }
コード例 #19
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
 public void Vector_rotatingM1_M1vector90degress_yieldsM1_1vectorOfSameLength()
 {
     Vector firstVec = new Vector(-1.0, -1.0, null);
      var firstAngle = firstVec.DirectionHorizontal;
      Vector secondVec = firstVec.rotateCloneAboutZ(Angle.AngleFactory(-90.0));
      Assert.AreEqual(expected: firstVec.Length, actual: secondVec.Length, delta: 0.00001);
      Assert.AreEqual(expected: firstVec.Azimuth.getAsDegreesDouble() - 90.0, actual: secondVec.Azimuth.getAsDegreesDouble(), delta: 0.00001);
 }
コード例 #20
0
ファイル: Vector.cs プロジェクト: catashd/NetVecCad
 public Vector crossProduct(Vector otherVec)
 {
     Vector newVec = new Vector();
      newVec.x = this.y * otherVec.z.Value - this.z.Value * otherVec.y;
      newVec.y = this.z.Value * otherVec.x - this.x * otherVec.z.Value;
      newVec.z = this.x * otherVec.y - this.y * otherVec.x;
      return newVec;
 }
コード例 #21
0
ファイル: UnitTestsNVcad.cs プロジェクト: catashd/NetVecCad
        public void Arc_CreateArc_ctor3DeflectingRight90_IsCorrect()
        {
            var anArc = new Arc(new Point(100.0, 100.0),
            Azimuth.ctorAzimuthFromDegree(90),
            Deflection.ctorDeflectionFromAngle(90.0, 1), 50.0);

             Assert.IsNotNull(anArc);

             Assert.AreEqual(
            expected: 0.0,
            actual: anArc.BeginRadiusVector.Azimuth.getAsDegreesDouble(),
            delta: 0.00001);
             Assert.AreEqual(
            expected: 90.0,
            actual: anArc.StartAzimuth.getAsDegreesDouble(),
            delta: 0.00001);
             Assert.IsNotNull(anArc.BoundingBox);
             Assertt.AreEqual(
            expected: new Point(100,50),
            actual: anArc.CenterPt);
             Assert.AreEqual(
            expected: 90.0,
            actual: anArc.Deflection.getAsDegreesDouble(),
            delta: 0.00001);
             Assert.AreEqual(
            expected: 0.0,
            actual: anArc.Eccentricity,
            delta: 0.00001);
             Assertt.AreEqual(
            expected: new Point(150.0, 50.0),
            actual: anArc.EndPt);
             var expecVec = new Vector(Azimuth.ctorAzimuthFromDegree(90.0),
            50.0);
             Assertt.AreEqual(
            expected: expecVec,
            actual: anArc.EndRadiusVector);
             Assertt.AreEqual(
            expected: new Point(100.0, 100.0),
            actual: anArc.Origin);
             Assert.AreEqual(
            expected: 50.0,
            actual: anArc.Radius,
            delta: 0.00001);
             Assert.AreEqual(
            expected: 0.0,
            actual: anArc.Rotation.getAsDegreesDouble(),
            delta: 0.00001);
             Double FiftyOverSR2 = 50.0 / Math.Sqrt(2.0);
             Assertt.AreEqual(
            expected: new Vector(FiftyOverSR2, FiftyOverSR2),
            actual: anArc.ScaleVector);
        }
コード例 #22
0
ファイル: BoundingBox.cs プロジェクト: catashd/NetVecCad
        public void setFrom_2dOnly(Point Center, Double totalWidth, Double totalHeight, Angle rotation)
        {
            // yea, the 3d version will require a quaternion.  Implement 3d maybe in 2015.
             Vector topRight = new Vector(totalWidth / 2.0, totalHeight / 2.0, null);
             var bottomRight = new Vector(topRight); bottomRight.flipAboutX_2d();
             var topLeft = new Vector(topRight); topLeft.flipAboutY_2d();
             var bottomLeft = new Vector(topRight); bottomLeft.ScaleBy(-1.0, -1.0, null);

             topRight.rotateAboutZ(rotation);
             bottomRight.rotateAboutZ(rotation);
             topLeft.rotateAboutZ(rotation);
             bottomLeft.rotateAboutZ(rotation);

             this.isInitialized = false;
             this.expandByPoint(Center + topRight);
             this.expandByPoint(Center + topLeft);
             this.expandByPoint(Center + bottomLeft);
             this.expandByPoint(Center + bottomRight);
        }