Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
Public Types | Public Member Functions | Friends | List of all members
hdi::core::Bezier Class Reference

Allows for cubic bezier calculations and manipulation (e.g. division, tangents, normals, etc.) More...

#include <hdicoreBezier.h>

Public Types

enum  AdjustmentResult { AdjustmentReflectedStartOut = 1 << 0, AdjustmentReflectedEndIn = 1 << 1, AdjustmentRotatedStartOut = 1 << 2, AdjustmentRotatedEndIn = 1 << 3 }
 Indicates what happened when a bezier was adjusted to pass through a point.
 

Public Member Functions

 Bezier ()
 Constructs a new Bezier object with all points at (0,0) More...
 
 Bezier (const Bezier &bez_)
 Constructs a new Bezier object from an existing Bezier object (copy constructor) More...
 
 Bezier (const ArtboardSegPoint &segPt1_, const ArtboardSegPoint &segPt2_)
 Constructs a new Bezier object from two segment endpoints. More...
 
 Bezier (const ArtboardPoint &start_, const ArtboardPoint &startOut_, const ArtboardPoint &endIn_, const ArtboardPoint &end_)
 Constructs a new Bezier object from individual component points. More...
 
virtual ~Bezier ()
 Destructs a Bezier object. More...
 
virtual Bezieroperator= (const Bezier &rhs_)
 Allows one Bezier object to be assigned from another. More...
 
virtual ArtboardPoint startPoint () const
 Gets the first anchor point of the bezier. More...
 
virtual ArtboardPoint startOutPoint () const
 Gets the first control point of the bezier. More...
 
virtual ArtboardPoint endInPoint () const
 Gets the second control point of the bezier. More...
 
virtual ArtboardPoint endPoint () const
 Gets the second anchor point of the bezier. More...
 
virtual AdjustmentResult adjustThruPoint (const ArtboardPoint &pt_, const double t_)
 Adjusts the bezier such that the given t-value will pass through the provided point. More...
 
virtual void divide (const double t_, Bezier &bez1__, Bezier &bez2__) const
 Splits the target bezier into two separate beziers at a given t-value. More...
 
virtual Bezier section (const double startT_, const double endT_) const
 Gets a section of the target bezier, from a starting t-value to an ending t-value. More...
 
virtual ArtboardPoint evaluate (const double t_) const
 Evaluates a given t-value along the target bezier as a point on the artboard. More...
 
virtual double length () const
 Gets the length of the bezier. More...
 
virtual double sublength (const double startT_, const double endT_) const
 Gives approximate length of a bezier from t-value startT_ to t-value endT_. More...
 
virtual double tAtLength (const double length_) const
 Gives the t-value at a specific length along the target bezier. More...
 
virtual void setPoints (const ArtboardPoint &start_, const ArtboardPoint &startOut_, const ArtboardPoint &endIn_, const ArtboardPoint &end_)
 Sets the anchor and control points of the bezier. More...
 
virtual Angle tangentAngle (const double t_) const
 Gets the tangent angle at some t-value along the bezier. More...
 
virtual Angle normalAngle (const double t_) const
 Gets the normal angle at some t-value along the bezier. More...
 
virtual bool curved () const
 Determines whether the bezier has a curved path. More...
 
virtual bool radius (const double t_, double &radius__) const
 Gets the radius of the curve at some t-value along the bezier. More...
 
virtual bool center (const double t_, ArtboardPoint &center__) const
 Gets the center point of the curve at some t-value along the bezier. More...
 
virtual bool radiusAndCenter (const double t_, double &radius__, ArtboardPoint &center__) const
 Gets both the radius and center point of the curve at some t-value along the bezier. More...
 
virtual bool isCircularArc () const
 Gets whether the bezier describes an arc segment of a circle. More...
 
virtual ArtboardRect bounds () const
 Gets the bounds rect for the target bezier. More...
 
virtual bool operator== (const Bezier &rhs_) const
 Tests whether a given Bezier object is the same as another. More...
 
virtual bool operator!= (const Bezier &rhs_) const
 Tests whether a given Bezier object is not the same as another. More...
 

Friends

plugin::Bezier * __accessImpl (const Bezier &)
 
Bezier __accessCtor (const plugin::Bezier &)
 

Detailed Description

Allows for cubic bezier calculations and manipulation (e.g. division, tangents, normals, etc.)

Constructor & Destructor Documentation

hdi::core::Bezier::Bezier ( )

Constructs a new Bezier object with all points at (0,0)

Author
GW
Date
08/2013
hdi::core::Bezier::Bezier ( const Bezier bez_)

Constructs a new Bezier object from an existing Bezier object (copy constructor)

Author
GW
Date
08/2013
Parameters
bez_Existing Bezier object
hdi::core::Bezier::Bezier ( const ArtboardSegPoint segPt1_,
const ArtboardSegPoint segPt2_ 
)

Constructs a new Bezier object from two segment endpoints.

Author
GW
Date
08/2013
Parameters
segPt1_First segment point
segPt2_Second segment point
Note
This will ultimately call setPoints() internally with args segPt1_.p, segPt1_.out, segPt2_.in, and segPt2_.p, respectively.
hdi::core::Bezier::Bezier ( const ArtboardPoint start_,
const ArtboardPoint startOut_,
const ArtboardPoint endIn_,
const ArtboardPoint end_ 
)

Constructs a new Bezier object from individual component points.

Author
GW
Date
08/2013
Parameters
start_First anchor point
startOut_First control point
endIn_Second control point
end_Second anchor point
virtual hdi::core::Bezier::~Bezier ( )
virtual

Destructs a Bezier object.

Author
GW
Date
08/2013

Member Function Documentation

virtual AdjustmentResult hdi::core::Bezier::adjustThruPoint ( const ArtboardPoint pt_,
const double  t_ 
)
virtual

Adjusts the bezier such that the given t-value will pass through the provided point.

Author
GW
Date
08/2013
Parameters
pt_Point the bezier should pass through at t_
t_T-value along the bezier to force through pt_
Returns
An enum value describing how the bezier was adjusted
virtual ArtboardRect hdi::core::Bezier::bounds ( ) const
virtual

Gets the bounds rect for the target bezier.

Author
GW
Date
08/2013
Returns
The rectangle that completely contains the target bezier
virtual bool hdi::core::Bezier::center ( const double  t_,
ArtboardPoint center__ 
) const
virtual

Gets the center point of the curve at some t-value along the bezier.

Author
GW
Date
08/2013
Parameters
t_T-value on the bezier whose radius is needed
center__Return-by-reference for the center point of the curve of the bezier at t_
Returns
true for success, false for failure (i.e. straight beziers do not have a center point)
virtual bool hdi::core::Bezier::curved ( ) const
virtual

Determines whether the bezier has a curved path.

Author
GW
Date
08/2013
Returns
true for curved beziers, false for straight
virtual void hdi::core::Bezier::divide ( const double  t_,
Bezier bez1__,
Bezier bez2__ 
) const
virtual

Splits the target bezier into two separate beziers at a given t-value.

Author
GW
Date
08/2013
Parameters
t_T-value along the target bezier to perform the split
bez1__Return-by-reference for the first bezier resulting from the split
bez2__Return-by-reference for the second bezier resulting from the split
virtual ArtboardPoint hdi::core::Bezier::endInPoint ( ) const
virtual

Gets the second control point of the bezier.

Author
GW
Date
08/2013
Returns
The second control point, AKA the end-in point
virtual ArtboardPoint hdi::core::Bezier::endPoint ( ) const
virtual

Gets the second anchor point of the bezier.

Author
GW
Date
08/2013
Returns
The second anchor point, AKA the end point
virtual ArtboardPoint hdi::core::Bezier::evaluate ( const double  t_) const
virtual

Evaluates a given t-value along the target bezier as a point on the artboard.

Author
GW
Date
08/2013
Parameters
t_T-value along the bezier for the point in question
Returns
The point for the given t-value along the target bezier
virtual bool hdi::core::Bezier::isCircularArc ( ) const
virtual

Gets whether the bezier describes an arc segment of a circle.

Author
GW
Date
08/2013
Returns
true if the bezier represents a circular arc segment, false otherwise
virtual double hdi::core::Bezier::length ( ) const
virtual

Gets the length of the bezier.

Author
GW
Date
08/2013
Returns
The length of the target bezier in points
virtual Angle hdi::core::Bezier::normalAngle ( const double  t_) const
virtual

Gets the normal angle at some t-value along the bezier.

Author
GW
Date
08/2013
Parameters
t_T-value on the bezier whose normal angle is needed
Returns
The angle of the normal at the given t-value, or the normal angle at 0.0 for values less than 0.0, or the normal angle at 1.0 for values greater than 1.0
virtual bool hdi::core::Bezier::operator!= ( const Bezier rhs_) const
virtual

Tests whether a given Bezier object is not the same as another.

Author
GW
Date
08/2013
Parameters
rhs_Bezier to compare against (righthand side of inequality operator)
Returns
true for the target and rhs_ being different beziers (having unequal anchor and control points), false otherwise
virtual Bezier& hdi::core::Bezier::operator= ( const Bezier rhs_)
virtual

Allows one Bezier object to be assigned from another.

Author
GW
Date
08/2013
Parameters
rhs_Righthand side of the = operator; the object to copy values from
Returns
The target Bezier object, but with its value updated to match that of rhs_
virtual bool hdi::core::Bezier::operator== ( const Bezier rhs_) const
virtual

Tests whether a given Bezier object is the same as another.

Author
GW
Date
08/2013
Parameters
rhs_Bezier to compare against (righthand side of equality operator)
Returns
true for the target and rhs_ being the same bezier (having equal anchor and control points), false otherwise
virtual bool hdi::core::Bezier::radius ( const double  t_,
double &  radius__ 
) const
virtual

Gets the radius of the curve at some t-value along the bezier.

Author
GW
Date
08/2013
Parameters
t_T-value on the bezier whose radius is needed
radius__Return-by-reference for the radius of the curve of the bezier at t_
Returns
true for success, false for failure (i.e. straight beziers do not have a radius)
virtual bool hdi::core::Bezier::radiusAndCenter ( const double  t_,
double &  radius__,
ArtboardPoint center__ 
) const
virtual

Gets both the radius and center point of the curve at some t-value along the bezier.

Author
GW
Date
08/2013
Parameters
t_T-value on the bezier whose radius is needed
radius__Return-by-reference for the radius of the curve of the bezier at t_
center__Return-by-reference for the center point of the curve of the bezier at t_
Returns
true for success, false for failure (i.e. straight beziers do not have a radius)
Note
Calculations for the radius and center point at a t-value are related, so use this method for performance reasons if you need both values.
virtual Bezier hdi::core::Bezier::section ( const double  startT_,
const double  endT_ 
) const
virtual

Gets a section of the target bezier, from a starting t-value to an ending t-value.

Author
GW
Date
08/2013
Parameters
startT_Starting position (t-value) of the bezier subsection
endT_Ending position (t-value) of the bezier subsection
Returns
A Bezier object describing the desired subsection of the original target bezier
virtual void hdi::core::Bezier::setPoints ( const ArtboardPoint start_,
const ArtboardPoint startOut_,
const ArtboardPoint endIn_,
const ArtboardPoint end_ 
)
virtual

Sets the anchor and control points of the bezier.

Author
GW
Date
08/2013
Parameters
start_First anchor point
startOut_First control point
endIn_Second control point
end_Second anchor point
virtual ArtboardPoint hdi::core::Bezier::startOutPoint ( ) const
virtual

Gets the first control point of the bezier.

Author
GW
Date
08/2013
Returns
The first control point, AKA the start-out point
virtual ArtboardPoint hdi::core::Bezier::startPoint ( ) const
virtual

Gets the first anchor point of the bezier.

Author
GW
Date
08/2013
Returns
The first anchor point, AKA the start point
virtual double hdi::core::Bezier::sublength ( const double  startT_,
const double  endT_ 
) const
virtual

Gives approximate length of a bezier from t-value startT_ to t-value endT_.

Author
GW
Date
08/2013
Parameters
startT_Starting position (t-value) to begin the calculation
endT_Ending position (t-value) to end the calculation
Returns
The length of the subsection of the target bezier between startT_ and endT_
virtual Angle hdi::core::Bezier::tangentAngle ( const double  t_) const
virtual

Gets the tangent angle at some t-value along the bezier.

Author
GW
Date
08/2013
Parameters
t_T-value on the bezier whose tangent angle is needed
Returns
The angle of the tangent at the given t-value, or the tangent angle at 0.0 for values less than 0.0, or the tangent angle at 1.0 for values greater than 1.0
virtual double hdi::core::Bezier::tAtLength ( const double  length_) const
virtual

Gives the t-value at a specific length along the target bezier.

Author
GW
Date
08/2013
Parameters
length_The length along the target bezier, in points, for which a t-value is desired
Returns
The t-value for the provided length, or 0.0 for negative lengths, or 1.0 for lengths greater than the total length of the target bezier