public override bool LogicalToLayerCoordinatesAndDirection(Logical3D r0, Logical3D r1, double t, out double ax, out double ay, out double adx, out double ady) { LogicalToLayerCoordinates(Logical3D.Interpolate(r0, r1, t), out ax, out ay); LogicalToLayerCoordinates(r0, out var x0, out var y0); LogicalToLayerCoordinates(r1, out var x1, out var y1); adx = x1 - x0; ady = y1 - y0; return(true); }
/// <summary> /// Converts logical coordinates along an isoline to layer coordinates and returns the direction of the isoline at this point. /// </summary> /// <param name="r0">Logical starting point of the isoline.</param> /// <param name="r1">Logical end point of the isoline.</param> /// <param name="t">Parameter between 0 and 1 that determines the point on the isoline. /// A value of 0 denotes the starting point of the isoline, a value of 1 the end point. The logical /// coordinates are linear interpolated between starting point and end point.</param> /// <param name="direction">Logical direction vector.</param> /// <param name="normalizeddirection">Returns the normalized direction vector,i.e. a vector of norm 1, that /// goes in the logical direction provided by the previous argument. </param> /// <returns>The location (in layer coordinates) of the isoline point.</returns> public virtual PointF GetNormalizedDirection( Logical3D r0, Logical3D r1, double t, Logical3D direction, out PointF normalizeddirection) { double ax, ay, adx, ady; Logical3D rn0 = Logical3D.Interpolate(r0, r1, t); Logical3D rn1 = rn0 + direction; this.LogicalToLayerCoordinatesAndDirection(rn0, rn1, 0, out ax, out ay, out adx, out ady); double hypot = Calc.RMath.Hypot(adx, ady); if (0 == hypot) { // then we look a little bit displaced - we might be at the midpoint where the directions are undefined double displT = t; if (displT < 0.5) { displT += 1E-6; } else { displT -= 1E-6; } Logical3D displR = Logical3D.Interpolate(r0, r1, displT); Logical3D displD = displR + direction; double dummyx, dummyy; LogicalToLayerCoordinatesAndDirection(displR, displD, 0, out dummyx, out dummyy, out adx, out ady); hypot = Calc.RMath.Hypot(adx, ady); } // Normalize the vector if (hypot > 0) { adx /= hypot; ady /= hypot; } normalizeddirection = new PointF((float)adx, (float)ady); return(new PointF((float)ax, (float)ay)); }
/// <summary> /// Converts logical coordinates along an isoline to layer coordinates and returns the direction of the isoline at this point. /// </summary> /// <param name="r0">Logical starting point of the isoline.</param> /// <param name="r1">Logical end point of the isoline.</param> /// <param name="t">Parameter between 0 and 1 that determines the point on the isoline. /// A value of 0 denotes the starting point of the isoline, a value of 1 the end point. The logical /// coordinates are linear interpolated between starting point and end point.</param> /// <param name="direction">Logical direction vector.</param> /// <param name="normalizeddirection">Returns the normalized direction vector,i.e. a vector of norm 1, that /// goes in the logical direction provided by the previous argument. </param> /// <returns>The location (in layer coordinates) of the isoline point.</returns> public virtual PointD3D GetPositionAndNormalizedDirection( Logical3D r0, Logical3D r1, double t, Logical3D direction, out VectorD3D normalizeddirection) { var rn0 = Logical3D.Interpolate(r0, r1, t); Logical3D rn1 = rn0 + direction; LogicalToLayerCoordinatesAndDirection(rn0, rn1, 0, out var pos, out var dir); double hypot = dir.Length; if (0 == hypot) { // then we look a little bit displaced - we might be at the midpoint where the directions are undefined double displT = t; if (displT < 0.5) { displT += 1E-6; } else { displT -= 1E-6; } var displR = Logical3D.Interpolate(r0, r1, displT); Logical3D displD = displR + direction; LogicalToLayerCoordinatesAndDirection(displR, displD, 0, out var dummyx, out dir); hypot = dir.Length; } // Normalize the vector if (hypot > 0) { dir /= hypot; } normalizeddirection = dir; return(pos); }