Class CubicCurve

java.lang.Object
org.graphstream.ui.javafx.util.CubicCurve

public class CubicCurve
extends Object
Utility methods to deal with cubic Bézier curves.
  • Constructor Summary

    Constructors 
    Constructor Description
    CubicCurve()  
  • Method Summary

    Modifier and Type Method Description
    static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​Double> approxIntersectionPointOnCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera)
    Use a dichotomy method to evaluate the intersection between the `edge` destination node shape and the Bézier curve of the connector `c`.
    static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​Double> approxIntersectionPointOnCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera, int maxDepth)
    Use a dichotomy method to evaluate the intersection between the `edge` destination node shape and the Bézier curve of the connector `c`.
    static double approxLengthOfCurve​(Connector c)
    Evaluate the length of a Bézier curve by taking n points on the curve and summing the lengths of the n+1 segments thus defined.
    static double approxLengthOfCurveQuick​(Connector c)
    Evaluate the length of a Bézier curve by taking four points on the curve and summing the lengths of the five segments thus defined.
    static double approxLengthOfCurveQuickAndDirty​(Connector c)
    A quick and dirty hack to evaluate the length of a cubic bezier curve.
    static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​org.graphstream.ui.geom.Point2> approxVectorEnteringCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera)
    Return two points, one inside and the second outside of the shape of the destination node of the given `edge`, the points can be used to deduce a vector along the Bézier curve entering point in the shape.
    static double derivative​(double x0, double x1, double x2, double x3, double t)
    Derivative of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
    static org.graphstream.ui.geom.Point2 derivative​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point3 p3, double t)
    Derivative point of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
    static org.graphstream.ui.geom.Point2 derivative​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point3 p3, double t, org.graphstream.ui.geom.Point2 result)
    Store in `result` the derivative point of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
    static double eval​(double x0, double x1, double x2, double x3, double t)
    Evaluate a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` and return the position at parametric position `t` of the curve.
    static javafx.geometry.Point2D eval​(javafx.geometry.Point2D p0, javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3, double t)
    Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
    static org.graphstream.ui.geom.Point2 eval​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t)
    Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
    static org.graphstream.ui.geom.Point2 eval​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t, org.graphstream.ui.geom.Point2 result)
    Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and store the position at parametric position `t` of the curve in `result`.
    static org.graphstream.ui.geom.Point3 eval​(org.graphstream.ui.geom.Point3 p0, org.graphstream.ui.geom.Point3 p1, org.graphstream.ui.geom.Point3 p2, org.graphstream.ui.geom.Point3 p3, double t)
    Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
    static javafx.geometry.Point2D perpendicular​(javafx.geometry.Point2D p0, javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3, double t)
    The perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.
    static org.graphstream.ui.geom.Vector2 perpendicular​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t)
    The perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.
    static org.graphstream.ui.geom.Vector2 perpendicular​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t, org.graphstream.ui.geom.Vector2 result)
    Store in `result` the perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • eval

      public static double eval​(double x0, double x1, double x2, double x3, double t)
      Evaluate a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` and return the position at parametric position `t` of the curve.
      Returns:
      The coordinate at parametric position `t` on the curve.
    • eval

      public static org.graphstream.ui.geom.Point2 eval​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t)
      Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
      Returns:
      The point at parametric position `t` on the curve.
    • eval

      public static org.graphstream.ui.geom.Point3 eval​(org.graphstream.ui.geom.Point3 p0, org.graphstream.ui.geom.Point3 p1, org.graphstream.ui.geom.Point3 p2, org.graphstream.ui.geom.Point3 p3, double t)
      Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
      Returns:
      The point at parametric position `t` on the curve.
    • eval

      public static javafx.geometry.Point2D eval​(javafx.geometry.Point2D p0, javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3, double t)
      Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and return the position at parametric position `t` of the curve.
      Returns:
      The point at parametric position `t` on the curve.
    • eval

      public static org.graphstream.ui.geom.Point2 eval​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t, org.graphstream.ui.geom.Point2 result)
      Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and store the position at parametric position `t` of the curve in `result`.
      Returns:
      the given reference to `result`.
    • derivative

      public static double derivative​(double x0, double x1, double x2, double x3, double t)
      Derivative of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
      Returns:
      The derivative at parametric position `t` on the curve.
    • derivative

      public static org.graphstream.ui.geom.Point2 derivative​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point3 p3, double t)
      Derivative point of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
      Returns:
      The derivative point at parametric position `t` on the curve.
    • derivative

      public static org.graphstream.ui.geom.Point2 derivative​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point3 p3, double t, org.graphstream.ui.geom.Point2 result)
      Store in `result` the derivative point of a cubic Bézier curve according to control points `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve.
      Returns:
      the given reference to `result`.
    • perpendicular

      public static org.graphstream.ui.geom.Vector2 perpendicular​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t)
      The perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.
      Returns:
      A vector perpendicular to the curve at position `t`.
    • perpendicular

      public static org.graphstream.ui.geom.Vector2 perpendicular​(org.graphstream.ui.geom.Point2 p0, org.graphstream.ui.geom.Point2 p1, org.graphstream.ui.geom.Point2 p2, org.graphstream.ui.geom.Point2 p3, double t, org.graphstream.ui.geom.Vector2 result)
      Store in `result` the perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.
      Returns:
      the given reference to `result`.
    • perpendicular

      public static javafx.geometry.Point2D perpendicular​(javafx.geometry.Point2D p0, javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3, double t)
      The perpendicular vector to the curve defined by control points `p0`, `p1`, `p2` and `p3` at parametric position `t`.
      Returns:
      A vector perpendicular to the curve at position `t`.
    • approxLengthOfCurveQuickAndDirty

      public static double approxLengthOfCurveQuickAndDirty​(Connector c)
      A quick and dirty hack to evaluate the length of a cubic bezier curve. This method simply compute the length of the three segments of the enclosing polygon and scale them. This is fast but inaccurate.
    • approxLengthOfCurveQuick

      public static double approxLengthOfCurveQuick​(Connector c)
      Evaluate the length of a Bézier curve by taking four points on the curve and summing the lengths of the five segments thus defined.
    • approxLengthOfCurve

      public static double approxLengthOfCurve​(Connector c)
      Evaluate the length of a Bézier curve by taking n points on the curve and summing the lengths of the n+1 segments thus defined.
    • approxVectorEnteringCurve

      public static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​org.graphstream.ui.geom.Point2> approxVectorEnteringCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera)
      Return two points, one inside and the second outside of the shape of the destination node of the given `edge`, the points can be used to deduce a vector along the Bézier curve entering point in the shape.
    • approxIntersectionPointOnCurve

      public static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​Double> approxIntersectionPointOnCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera)
      Use a dichotomy method to evaluate the intersection between the `edge` destination node shape and the Bézier curve of the connector `c`. The returned values are the point of intersection as well as the parametric position of this point on the curve (a float). The maximal recursive depth of the dichotomy is fixed to 7 here.
      Returns:
      A 2-tuple made of the point of intersection and the associated parametric position.
    • approxIntersectionPointOnCurve

      public static AttributeUtils.Tuple<org.graphstream.ui.geom.Point2,​Double> approxIntersectionPointOnCurve​(org.graphstream.ui.graphicGraph.GraphicEdge edge, Connector c, org.graphstream.ui.view.camera.DefaultCamera2D camera, int maxDepth)
      Use a dichotomy method to evaluate the intersection between the `edge` destination node shape and the Bézier curve of the connector `c`. The returned values are the point of intersection as well as the parametric position of this point on the curve (a float). The dichotomy can recurse at any level to increase precision, often 7 is sufficient, the `maxDepth` parameter allows to set this depth.
      Returns:
      A 2-tuple made of the point of intersection and the associated parametric position.