public Parametrisation FindNearest( IParametricSurface surface, Point3D referencePoint ) { Parametrisation closestParametrisation = new Parametrisation(); var closestDistance = double.MaxValue; for (var u = 0; u < SamplesU; ++u) { for (var v = 0; v < SamplesV; ++v) { var paramU = u / (SamplesU - 1.0); var paramV = v / (SamplesV - 1.0); var location = surface.Evaluate(paramU, paramV); var distance = (referencePoint - location).Length; if (closestDistance > distance) { closestDistance = distance; closestParametrisation = new Parametrisation( paramU, paramV ); } } } return(closestParametrisation); }
public static Point3D Evaluate( this IParametricSurface surface, Parametrisation parametrisation ) { return(surface.Evaluate( parametrisation.U, parametrisation.V )); }
public void DrawDerivative( IParametricSurface surface, double u, double v, DerivativeParameter parameter, Color?color = null ) { var point = surface.Evaluate(u, v); var derivative = surface.Derivative(u, v, parameter); DrawVector(point, derivative, derivative.Length, color); }
/// <summary> /// Calculates F(u,v) = dot(P(u,v) - P, t) - d /// </summary> /// <param name="surface"></param> /// <param name="parametrisation"></param> /// <param name="previousPoint"></param> /// <param name="tangentVector"></param> /// <returns></returns> private DenseVector EvaluatePlaneEquation( IParametricSurface surface, Parametrisation parametrisation, Vector previousPoint, Vector tangentVector ) { var surfacePosition = ((Vector3D)surface.Evaluate(parametrisation)).ToMathVector(); var position = surfacePosition - previousPoint; var dot = position.DotProduct(tangentVector); var tangentZeroEquationValue = dot - TrackingDistance; var tantentPlaneEquationVector = DenseVector.OfArray(new[] { tangentZeroEquationValue, tangentZeroEquationValue, tangentZeroEquationValue }); return(tantentPlaneEquationVector); }
protected void ScanConstantParameter( Func <int, double> uCoordGenerator, Func <int, double> vCoordGenerator, int samples) { for (var i = 0; i < samples; ++i) { var u = uCoordGenerator(i); var v = vCoordGenerator(i); if (_sampledSurface.Trimmer != null && !_sampledSurface.Trimmer.VerifyParametrisation(u, v)) { _builder.FinishChain(); } else { _builder.Connect(_sampledSurface.Evaluate(u, v)); } } _builder.FinishChain(); }