libsurf
Programmer's Documentation

beziersegment.h (r6227/r5760)
1 #ifndef SURF_BEZIERSEGMENT_H
2 #define SURF_BEZIERSEGMENT_H
3 
4 #include "abstractcurve.h"
5 
14 {
15 public:
16 
18  explicit BezierSegment(const std::string &s = "") : AbstractCurve(s) {}
19 
21  explicit BezierSegment(const Vct3 &p0, const Vct3 &t0,
22  const Vct3 &p1, const Vct3 &t1) : AbstractCurve("")
23  {
24  byTangents(p0, t0, p1, t1);
25  }
26 
28  virtual BezierSegment *clone() const;
29 
31  void byTangents(const Vct3 &p0, const Vct3 &t0,
32  const Vct3 &p1, const Vct3 &t1);
33 
35  const Vct3 *controls() const {return m_cp;}
36 
38  Vct3 eval(Real t) const {
39  return ( 1 - cb(t) ) * m_cp[0]
40  + 3*sq(1 - t)*t * m_cp[1]
41  + 3*(1-t)*sq(t) * m_cp[2]
42  + cb(t) * m_cp[3];
43  }
44 
46  Vct3 derive(Real t, uint k) const;
47 
49  void apply();
50 
51 protected:
52 
54  Vct3 m_cp[4];
55 };
56 
57 #endif // BEZIERSEGMENT_H
Base class for all curve objects.
Definition: abstractcurve.h:31
Vct3 m_cp[4]
four control points
Definition: beziersegment.h:54
void byTangents(const Vct3 &p0, const Vct3 &t0, const Vct3 &p1, const Vct3 &t1)
construct a Bezier segment from points and tangents
Definition: beziersegment.cpp:9
BezierSegment(const std::string &s="")
undefined segment
Definition: beziersegment.h:18
BezierSegment(const Vct3 &p0, const Vct3 &t0, const Vct3 &p1, const Vct3 &t1)
segment defined by two points and two tangents
Definition: beziersegment.h:21
Vct3 derive(Real t, uint k) const
compute kth derivative
Definition: beziersegment.cpp:18
Vct3 eval(Real t) const
evaluate spline curve
Definition: beziersegment.h:38
void apply()
apply hard transformation
Definition: beziersegment.cpp:34
Single cubic Bezier segment.
Definition: beziersegment.h:13
const Vct3 * controls() const
access the array of 4 control points
Definition: beziersegment.h:35
virtual BezierSegment * clone() const
create a clone
Definition: beziersegment.cpp:4
Generated on Wed Jan 19 2022 03:03:14 for libsurf by   doxygen 1.8.5