Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CurveFitter Class Reference

Classes

class  DataPoint
 

Public Types

typedef pvector< DataPointData
 

Public Member Functions

void add_hpr (PN_stdfloat t, const LVecBase3 &hpr)
 Adds a single sample hpr. More...
 
void add_xyz (PN_stdfloat t, const LVecBase3 &xyz)
 Adds a single sample xyz. More...
 
void add_xyz_hpr (PN_stdfloat t, const LVecBase3 &xyz, const LVecBase3 &hpr)
 Adds a single sample xyz & hpr simultaneously. More...
 
void compute_tangents (PN_stdfloat scale)
 Once a set of points has been built, and prior to calling MakeHermite() or MakeNurbs(), ComputeTangents() must be called to set up the tangents correctly (unless the tangents were defined as the points were added). More...
 
void desample (PN_stdfloat factor)
 Removes sample points in order to reduce the complexity of a sampled curve. More...
 
int get_num_samples () const
 Returns the number of sample points that have been added. More...
 
LVecBase3 get_sample_hpr (int n) const
 Returns the orientation of the nth sample added. More...
 
PN_stdfloat get_sample_t (int n) const
 Returns the parametric value of the nth sample added. More...
 
LVecBase3 get_sample_tangent (int n) const
 Returns the tangent associated with the nth sample added. More...
 
LVecBase3 get_sample_xyz (int n) const
 Returns the point in space of the nth sample added. More...
 
void output (ostream &out) const
 
 PT (ParametricCurveCollection) make_hermite() const
 
 PT (ParametricCurveCollection) make_nurbs() const
 
void remove_samples (int begin, int end)
 Eliminates all samples from index begin, up to but not including index end, from the database. More...
 
void reset ()
 Removes all the data points previously added to the CurveFitter, and initializes it for a new curve. More...
 
void sample (ParametricCurveCollection *curves, int count)
 Generates a series of data points by sampling the given curve (or xyz/hpr curves) the indicated number of times. More...
 
void sort_points ()
 Sorts all the data points in order by parametric time, in case they were added in an incorrect order. More...
 
void wrap_hpr ()
 Resets each HPR data point so that the maximum delta between any two consecutive points is 180 degrees, which should prevent incorrect HPR wrapping. More...
 
void write (ostream &out) const
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

Data _data
 
bool _got_hpr
 
bool _got_xyz
 

Detailed Description

Definition at line 35 of file curveFitter.h.

Member Function Documentation

◆ add_hpr()

void CurveFitter::add_hpr ( PN_stdfloat  t,
const LVecBase3 hpr 
)

Adds a single sample hpr.

Definition at line 78 of file curveFitter.cxx.

References add_xyz_hpr().

Referenced by add_xyz(), and ParametricCurveCollection::face_forward().

◆ add_xyz()

void CurveFitter::add_xyz ( PN_stdfloat  t,
const LVecBase3 xyz 
)

Adds a single sample xyz.

Definition at line 64 of file curveFitter.cxx.

References add_hpr().

Referenced by ParametricCurveCollection::make_even(), and reset().

◆ add_xyz_hpr()

void CurveFitter::add_xyz_hpr ( PN_stdfloat  t,
const LVecBase3 xyz,
const LVecBase3 hpr 
)

Adds a single sample xyz & hpr simultaneously.

Definition at line 92 of file curveFitter.cxx.

References get_num_samples().

Referenced by add_hpr().

◆ compute_tangents()

void CurveFitter::compute_tangents ( PN_stdfloat  scale)

Once a set of points has been built, and prior to calling MakeHermite() or MakeNurbs(), ComputeTangents() must be called to set up the tangents correctly (unless the tangents were defined as the points were added).

Definition at line 294 of file curveFitter.cxx.

References NurbsCurve::get_knot(), ParametricCurveCollection::get_num_curves(), NurbsCurve::get_num_knots(), HermiteCurve::insert_cv(), NurbsCurve::recompute(), ParametricCurve::set_curve_type(), HermiteCurve::set_cv_in(), HermiteCurve::set_cv_out(), HermiteCurve::set_cv_point(), HermiteCurve::set_cv_type(), and NurbsCurve::set_knot().

Referenced by desample(), ParametricCurveCollection::face_forward(), and ParametricCurveCollection::make_even().

◆ desample()

void CurveFitter::desample ( PN_stdfloat  factor)

Removes sample points in order to reduce the complexity of a sampled curve.

Keeps one out of every factor samples. Also keeps the first and the last samples.

Definition at line 264 of file curveFitter.cxx.

References compute_tangents().

Referenced by sort_points().

◆ get_num_samples()

int CurveFitter::get_num_samples ( ) const

Returns the number of sample points that have been added.

Definition at line 109 of file curveFitter.cxx.

References get_sample_t().

Referenced by add_xyz_hpr().

◆ get_sample_hpr()

LVecBase3 CurveFitter::get_sample_hpr ( int  n) const

Returns the orientation of the nth sample added.

Definition at line 141 of file curveFitter.cxx.

References get_sample_tangent(), and LVecBase3f::zero().

Referenced by get_sample_xyz().

◆ get_sample_t()

PN_stdfloat CurveFitter::get_sample_t ( int  n) const

Returns the parametric value of the nth sample added.

Definition at line 119 of file curveFitter.cxx.

References get_sample_xyz().

Referenced by get_num_samples().

◆ get_sample_tangent()

LVecBase3 CurveFitter::get_sample_tangent ( int  n) const

Returns the tangent associated with the nth sample added.

This is only meaningful if compute_tangents() has already been called.

Definition at line 154 of file curveFitter.cxx.

References remove_samples(), and LVecBase3f::zero().

Referenced by get_sample_hpr().

◆ get_sample_xyz()

LVecBase3 CurveFitter::get_sample_xyz ( int  n) const

Returns the point in space of the nth sample added.

Definition at line 130 of file curveFitter.cxx.

References get_sample_hpr(), and LVecBase3f::zero().

Referenced by get_sample_t().

◆ remove_samples()

void CurveFitter::remove_samples ( int  begin,
int  end 
)

Eliminates all samples from index begin, up to but not including index end, from the database.

Definition at line 166 of file curveFitter.cxx.

References sample().

Referenced by get_sample_tangent().

◆ reset()

void CurveFitter::reset ( )

Removes all the data points previously added to the CurveFitter, and initializes it for a new curve.

Definition at line 54 of file curveFitter.cxx.

References add_xyz().

◆ sample()

void CurveFitter::sample ( ParametricCurveCollection curves,
int  count 
)

Generates a series of data points by sampling the given curve (or xyz/hpr curves) the indicated number of times.

The sampling is made evenly in parametric time, and then the timewarps, if any, are applied.

Definition at line 184 of file curveFitter.cxx.

References ParametricCurveCollection::evaluate(), ParametricCurveCollection::get_hpr_curve(), ParametricCurveCollection::get_max_t(), ParametricCurveCollection::get_xyz_curve(), and wrap_hpr().

Referenced by remove_samples().

◆ sort_points()

void CurveFitter::sort_points ( )

Sorts all the data points in order by parametric time, in case they were added in an incorrect order.

Definition at line 251 of file curveFitter.cxx.

References desample().

Referenced by wrap_hpr().

◆ wrap_hpr()

void CurveFitter::wrap_hpr ( )

Resets each HPR data point so that the maximum delta between any two consecutive points is 180 degrees, which should prevent incorrect HPR wrapping.

Definition at line 219 of file curveFitter.cxx.

References sort_points().

Referenced by ParametricCurveCollection::face_forward(), HermiteCurve::rebuild_curveseg(), and sample().


The documentation for this class was generated from the following files: