/// <summary> /// Compute parabola operations. /// </summary> /// <param name="computedParabola">Parabola to be computed</param> /// <param name="considerAngle">Calculate Parabola plane by angle</param> /// <returns>true if it is valid parabola</returns> private int ComputeParabola(ref ParabolaComputation computedParabola, bool considerAngle) { if (computedParabola.IterateParabola() < 1) { return(-1); } int min = -1; double minDiff = 1e10; bool sameSide = false; for (int i = 0; i < computedParabola.MaximumResult; i++) { if (!considerAngle) { bool same = false; double diff = computedParabola.GetAngleStateCount(i, ref same); if (diff.IsEqual(-1)) { continue; } if (sameSide && !same) { continue; } //if (diff.IsLesser(minDiff) || (!sameSide && same)) if (diff < minDiff || (!sameSide && same)) { min = i; minDiff = diff; sameSide = same; } } else { double diff = computedParabola.GetAngleState(i, ref sameSide, ParabolaAxisAngle); if (diff.IsEqual(-1)) //TODO porovnani na presnost ? { continue; } //if (!computedParabola.GetAngleState(i, ref sameSide, ref diff)) //{ // continue; //} //if (diff.IsLesser(minDiff)) if (diff < minDiff) { min = i; minDiff = diff; } } } return(min); }
/// <summary> /// Calculate the plane of parabola. /// </summary> /// <param name="ca">Direction Vector between start and intermediate</param> /// <param name="cb">Direction Vector between end and intermediate</param> /// <param name="angleOfParabola">Axis angle of parabola</param> /// <param name="vectorOrtho">Perpendicular Vector</param> /// <param name="normalizedVector">Parabola Normal</param> /// <param name="considerAngle">Calculate Parabola plane by angle</param> /// <returns>true if parabola is in plane</returns> private bool CalculateParabolaPlane(Vector3D ca, Vector3D cb, ref double angleOfParabola, ref Vector3D vectorOrtho, ref Vector3D normalizedVector, bool considerAngle) { ParabolaComputation computedParabola = new ParabolaComputation(ca, cb); int result = ComputeParabola(ref computedParabola, considerAngle); if (result == -1) { return(false); } angleOfParabola = computedParabola.ResultCollection[result]; vectorOrtho = computedParabola.GetY(angleOfParabola); normalizedVector = computedParabola.NormalizedVector; //normalizedVector = vectorOrtho * computedParabola.NormalizedVector; return(true); }