QCurve

scalation.scala2d.QCurve
See theQCurve companion object
case class QCurve(p1: R2, pc: R2, p2: R2, straight: Boolean) extends Double, CurvilinearShape

The QCurve class enhances the QuadCurve.Double class (from the java.awt.geom package) by allowing entities to move along such quadratic curves as well as lines. Although the curve could be developed as a quadratic function where y = ax^2 + bx + c. The following quadratic bezier formulation is used: p(t) = (x(t), y(t)) = [(1-t)^2 * p1] + [2 * (1-t) * t * pc] + [t^2 * p2].

Value parameters

p1

the starting point for the quad curve

p2

the ending point for the quad curve

pc

the control point for the quad curve

straight

whether the quad curve is straight (i.e., a line)

Attributes

Companion
object
Graph
Supertypes
trait Product
trait Equals
class Double
trait Serializable
class QuadCurve2D
trait Cloneable
trait Shape
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(_p1: R2, _p2: R2)

Construct a straight line (degenerate quad curve).

Construct a straight line (degenerate quad curve).

Value parameters

_p1

the starting point

_p2

the ending point

Attributes

def this(_p1: R2, _p2: R2, bend: Double)

Construct a quad curve where bend indicates the distance to the control point.

Construct a quad curve where bend indicates the distance to the control point.

Value parameters

_p1

the starting point

_p2

the ending point

bend

the bend or curvature (1. => line length)

Attributes

Concrete methods

def eval(): R2

Given a value for the trajectory parameter 't' (in [0., 1.]) calculate the point on the curve using the Quadratic Bezier equation.

Given a value for the trajectory parameter 't' (in [0., 1.]) calculate the point on the curve using the Quadratic Bezier equation.

Attributes

See also

en.wikipedia.org/wiki/Bézier_curve#Quadratic_curves

def getCenterX: Double

Get the x-coordinate of the center of the line/curve.

Get the x-coordinate of the center of the line/curve.

Attributes

def getCenterY: Double

Get the y-coordinate of the center of the line/curve.

Get the y-coordinate of the center of the line/curve.

Attributes

def getControl: R2

Get the control point of the quad curve.

Get the control point of the quad curve.

Attributes

def getFirst: R2

Get the first/start point of the quad curve.

Get the first/start point of the quad curve.

Attributes

def getFirst(width: Double, height: Double): R2

Get the first/start point of the quad curve, adjusted from top-left to center coordinates.

Get the first/start point of the quad curve, adjusted from top-left to center coordinates.

Value parameters

height

the height of object traversing the curve

width

the width of object traversing the curve

Attributes

def getLast: R2

Get the last/end-point of the quad curve.

Get the last/end-point of the quad curve.

Attributes

def getLast(width: Double, height: Double): R2

Get the last/end-point of the quad curve, adjusted from top-left to center coordinates.

Get the last/end-point of the quad curve, adjusted from top-left to center coordinates.

Value parameters

height

the height of object traversing the curve

width

the width of object traversing the curve

Attributes

def isSame(x: Double, y: Double, xe: Double, ye: Double, step: Double): Boolean

Whether ('x', 'y') and ('xe', 'ye') are essentially the same.

Whether ('x', 'y') and ('xe', 'ye') are essentially the same.

Attributes

def length: Double

Return the length of this QCurve.

Return the length of this QCurve.

Attributes

def next(): R2

Return the next point on the quad curve (one step beyond current point). Return null if 't > 1.0' (i.e., past end-point).

Return the next point on the quad curve (one step beyond current point). Return null if 't > 1.0' (i.e., past end-point).

Attributes

override def next(width: Double, height: Double): R2

Return the next point on the quad curve (one step beyond current point) and adjust from top-left to center coordinates for the object traversing the curve based on its width and height. Return null if 't > 1.0' (i.e., past end-point).

Return the next point on the quad curve (one step beyond current point) and adjust from top-left to center coordinates for the object traversing the curve based on its width and height. Return null if 't > 1.0' (i.e., past end-point).

Value parameters

height

the height of object traversing the curve

width

the width of object traversing the curve

Attributes

Definition Classes
def setLine(_p1: R2, _p2: R2): Unit

Set (or reset) the location for the QCurve as a line.

Set (or reset) the location for the QCurve as a line.

Value parameters

_p1

the starting point

_p2

the ending point

Attributes

def setLine(_p1: R2, _p2: R2, bend: Double): Unit

Set (or reset) the location for the QCurve as a curve using bend to calculate the control point.

Set (or reset) the location for the QCurve as a curve using bend to calculate the control point.

Value parameters

_p1

the starting point

_p2

the ending point

bend

the bend or curvature (1. => line-length)

Attributes

override def setLine(_p1: R2, _pc: R2, _p2: R2): Unit

Set (or reset) the location for the QCurve as a curve using an explicitly given control point.

Set (or reset) the location for the QCurve as a curve using an explicitly given control point.

Value parameters

_p1

the starting point

_p2

the ending point

_pc

the control point

Attributes

Definition Classes
def setSteps(_steps: Int): Unit

Set the number of steps for tokens to take as move along the quad curve.

Set the number of steps for tokens to take as move along the quad curve.

Value parameters

steps

the number of steps to take along the quad curve

Attributes

override def toString: String

Show the start, control and end-points of the the QCurve.

Show the start, control and end-points of the the QCurve.

Attributes

Definition Classes
Any
def traj: Double

Get the current trajectory '_traj' of the curve.

Get the current trajectory '_traj' of the curve.

Attributes

def traj_=(traj: Double): Unit

Set the trajectory '_traj' to a new value.

Set the trajectory '_traj' to a new value.

Value parameters

traj

the new trajectory for the curve

Attributes

Inherited methods

def clone(): <FromJavaObject>

Create a copy of the receiver object.

Create a copy of the receiver object.

The default implementation of the clone method is platform dependent.

Attributes

Returns

a copy of the receiver object.

Note

not specified by SLS as a member of AnyRef

Inherited from:
QuadCurve2D
def contains(x$0: Rectangle2D): Boolean

Attributes

Inherited from:
QuadCurve2D
def contains(x$0: Double, x$1: Double, x$2: Double, x$3: Double): Boolean

Attributes

Inherited from:
QuadCurve2D
def contains(x$0: Point2D): Boolean

Attributes

Inherited from:
QuadCurve2D
def contains(x$0: Double, x$1: Double): Boolean

Attributes

Inherited from:
QuadCurve2D
def getBounds(): Rectangle

Attributes

Inherited from:
QuadCurve2D
def getBounds2D(): Rectangle2D

Attributes

Inherited from:
QuadCurve2D
def getCtrlPt(): Point2D

Attributes

Inherited from:
Double
def getCtrlX(): Double

Attributes

Inherited from:
Double
def getCtrlY(): Double

Attributes

Inherited from:
Double
def getFlatness(): Double

Attributes

Inherited from:
QuadCurve2D
def getFlatnessSq(): Double

Attributes

Inherited from:
QuadCurve2D
def getP1(): Point2D

Attributes

Inherited from:
Double
def getP2(): Point2D

Attributes

Inherited from:
Double
def getPathIterator(x$0: AffineTransform, x$1: Double): PathIterator

Attributes

Inherited from:
QuadCurve2D
def getPathIterator(x$0: AffineTransform): PathIterator

Attributes

Inherited from:
QuadCurve2D
def getX1(): Double

Attributes

Inherited from:
Double
def getX2(): Double

Attributes

Inherited from:
Double
def getY1(): Double

Attributes

Inherited from:
Double
def getY2(): Double

Attributes

Inherited from:
Double
def intersects(x$0: Rectangle2D): Boolean

Attributes

Inherited from:
QuadCurve2D
def intersects(x$0: Double, x$1: Double, x$2: Double, x$3: Double): Boolean

Attributes

Inherited from:
QuadCurve2D
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def setCurve(x$0: Double, x$1: Double, x$2: Double, x$3: Double, x$4: Double, x$5: Double): Unit

Attributes

Inherited from:
Double
def setCurve(x$0: QuadCurve2D): Unit

Attributes

Inherited from:
QuadCurve2D
def setCurve(x$0: Array[Point2D], x$1: Int): Unit

Attributes

Inherited from:
QuadCurve2D
def setCurve(x$0: Point2D, x$1: Point2D, x$2: Point2D): Unit

Attributes

Inherited from:
QuadCurve2D
def setCurve(x$0: Array[Double], x$1: Int): Unit

Attributes

Inherited from:
QuadCurve2D
def setLine(p1: VectorD, pc: VectorD, p2: VectorD): Unit

Attributes

Inherited from:
CurvilinearShape
def setLine(p1: VectorD, p2: VectorD, bend: Double): Unit

Attributes

Inherited from:
CurvilinearShape
def setLine(p1: VectorD, p2: VectorD): Unit

Attributes

Inherited from:
CurvilinearShape
def subdivide(x$0: QuadCurve2D, x$1: QuadCurve2D): Unit

Attributes

Inherited from:
QuadCurve2D

Concrete fields

var _traj: Double

Trajectory parameter t ranges from 0. to 1. (indicates how far along the curve)

Trajectory parameter t ranges from 0. to 1. (indicates how far along the curve)

Attributes

Inherited fields

var ctrlx: Double

Attributes

Inherited from:
Double
var ctrly: Double

Attributes

Inherited from:
Double
var x1: Double

Attributes

Inherited from:
Double
var x2: Double

Attributes

Inherited from:
Double
var y1: Double

Attributes

Inherited from:
Double
var y2: Double

Attributes

Inherited from:
Double