/// <summary> /// Calculate Point on parabola. /// </summary> /// <param name="segmentParabola">Segment Parabola</param> /// <param name="relativePosition">Relative Position</param> /// <param name="point">Point On Parabola</param> /// <returns>true if given input are valid</returns> internal bool GetPointOnParabola(IArcSegment3D segmentParabola, double relativePosition, ref IPoint3D point) { if (segmentParabola == null) { throw new ArgumentNullException(); } if (!IsValid) { IPoint3D a = segmentParabola.StartPoint; IPoint3D b = segmentParabola.IntermedPoint; point = GeomOperation.Add(GeomOperation.Multiply(b, relativePosition), GeomOperation.Multiply(a, 1 - relativePosition)); return(true); } double x = 0; // CIH - nejak jsem ty Abs nepochopil // if (Math.Abs(relativePosition).IsLesser(0.0)) // { // x = parabolaProperty.ParabolicArcX1; // } // else if (Math.Abs(relativePosition - 1.0).IsLesser(0.0)) // { // x = parabolaProperty.ParabolicArcX2; // } // else if (Math.Abs(parabolaProperty.ParabolaAxisAngle).IsLesser(0.0)) if (relativePosition.IsEqual(0.0)) { x = ParabolicArcX1; } else if (relativePosition.IsEqual(1.0)) { x = ParabolicArcX2; } //else if (ParabolaAxisAngle.IsLesser(0.0)) //{ // x = relativePosition * (ParabolicArcX2 - ParabolicArcX1) + ParabolicArcX1; //} else { x = 0.0; int it = 100; double pom = relativePosition * ParabolaLength + GetLengthToCurve(ParabolicArcX1); double caa = 4 * ParabolaAxisAngle * ParabolaAxisAngle; double len = pom; do { x += len / Math.Sqrt(1 + caa * x * x); len = pom - GetLengthToCurve(x); }while ((!len.IsZero(MathConstants.ZeroGeneral)) && (--it > 0)); //while ((!Math.Abs(len).IsLesser(0.0)) && (--it > 0)); if (Math.Abs(len) > 1e-8) { return(false); } } Vector3D normline = Matrix.AxisX; Vector3D ortho = Matrix.AxisY; point = GeomOperation.Add(segmentParabola.IntermedPoint, normline * x + ParabolaAxisAngle * ortho * x * x); return(true); }
/// <summary> /// Transforms a Point from LCS to GCS /// </summary> /// <param name="point">Point to be tranformed [In LCS].</param> /// <returns>Point in GCS</returns> public WM.Point3D TransformToGCS(WM.Point3D point) { return(GeomOperation.Add(Multiply(point, this), this.Origin)); }