/// <summary> /// Build arc by 3 given points /// ( the inside CS will centered in the arc center and Xaxis toward p1 ) /// </summary> public Arc3D(double tol_len, Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal = null) : base(GeometryType.Arc3D) { Type = GeometryType.Arc3D; var nfo = Arc3D.CircleBy3Points(p1, p2, p3); CS = nfo.CS; Radius = nfo.Radius; if (normal != null) { if (!normal.Colinear(tol_len, CS.BaseZ)) { throw new Exception($"invalid given normal not colinear to arc axis"); } if (!normal.Concordant(tol_len, CS.BaseZ)) { CS = CS.Rotate(CS.BaseX, PI); } } AngleStartRad = CS.BaseX.AngleToward(tol_len, p1 - CS.Origin, CS.BaseZ); AngleEndRad = CS.BaseX.AngleToward(tol_len, p3 - CS.Origin, CS.BaseZ); }
public void CoordinateSystem3DTest_001() { var cs1cad = new CoordinateSystem3D(new Vector3D(-1, 77, .75), new Vector3D(0, 0, 1), new Vector3D(.619, -.785, 0), new Vector3D(.785, .619, 0)); var rotationAxis = new Line3D(new Vector3D(.111, .652, 0), Vector3D.ZAxis, Line3DConstructMode.PointAndVector); var cs2 = cs1cad.Rotate(rotationAxis, 74.1566195.ToRad()); var cs2cad = new CoordinateSystem3D(new Vector3D(-73.639, 20.427, .75), new Vector3D(0, 0, 1), new Vector3D(.924, .381, 0), new Vector3D(-.381, .924, 0)); Assert.True(cs2.Equals(1e-3, cs2cad)); }
public void CoordinateSystem3DTest_004() { var cs1cad = new CoordinateSystem3D(new Vector3D(-1, 77, .75), new Vector3D(0, 0, 1), new Vector3D(.619, -.785, 0), new Vector3D(.785, .619, 0)); var cs2cad = new CoordinateSystem3D(new Vector3D(-1, 77, .75), new Vector3D(-0.649, .409, .642), new Vector3D(-.108, -.884, .454), new Vector3D(.753, .225, .618)); var vaxis = new Vector3D(-.311, -1.15, -.75); Assert.True(cs1cad.Rotate(vaxis, 60d.ToRad()).Equals(1e-3, cs2cad)); var pt = new Vector3D(-1.379, 76.762, 1.298); Assert.True(cs2cad.Contains(1e-3, pt) && !cs1cad.Contains(1e-3, pt)); }