Atoms Crowd  7.0.0
Curve.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <AtomsUtils/Globals.h>
11 #include <AtomsUtils/AtomsMath.h>
12 #include <vector>
13 
14 namespace AtomsUtils
15 {
17  class ATOMSUTILS_EXPORT Curve
18  {
19  public:
20 
22  Curve();
23 
25 
29  Curve(const std::vector<AtomsMath::Vector3f> cvs, unsigned int degree);
30 
32  virtual ~Curve();
33 
35 
38  int findSpan(float u) const;
39 
41 
46  int findKnot(float u) const;
47 
49 
54  int findMult(int r) const;
55 
57 
60 
62 
66  std::vector<float> basis(int knotSpan, float u) const;
67 
69 
72  std::vector<std::vector<float> > dersBasis(int knotSpan, float u, unsigned int degree) const;
73 
75 
78  AtomsMath::Vector3f pointOnCurve(float param) const;
79 
81 
84  AtomsMath::Vector3f tangentOnCurve(float param) const;
85 
87 
91  std::vector<AtomsMath::Vector3f> curveDerivs(float param, unsigned int nderiv) const;
92 
94 
98  std::vector<AtomsMath::Vector3f> parallelFrameNormals(unsigned int samples, AtomsMath::Vector3f upVec) const;
99 
101 
106  AtomsMath::Matrixf parallelFrameAtPoint(unsigned int samples, AtomsMath::Vector3f upVec, float param) const;
107 
109 
114  virtual std::pair<float,AtomsMath::Vector3f> closestPoint(const AtomsMath::Vector3f& point, unsigned int maxStep = 6, unsigned int maxIterations = 10, float tollarence = 0.0001f);
115 
117 
122  virtual std::pair<float, AtomsMath::Vector3f> closestTangent(const AtomsMath::Vector3f& point, unsigned int maxStep = 6, unsigned int maxIterations = 10, float tollarence = 0.0001f);
123 
125  float maxU() const;
126 
128  std::vector<AtomsMath::Vector3f>& cvs();
129 
131  const std::vector<AtomsMath::Vector3f>& cvs() const;
132 
134  std::vector<float>& knots();
135 
137  const std::vector<float>& knots() const;
138 
140  unsigned int degree() const;
141 
143  void setDegree(unsigned int degree);
144 
146  const Curve & operator=(const Curve &curve);
147 
148  private:
149 
151  std::vector<AtomsMath::Vector3f> m_cvs;
152 
154  std::vector<float> m_knots;
155 
157  unsigned int m_degree;
158  };
159 }
160 
161 
Nurbs curve.
Definition: Curve.h:18
const Curve & operator=(const Curve &curve)
Assign operator.
int findSpan(float u) const
Find span.
const std::vector< AtomsMath::Vector3f > & cvs() const
Ge curve cvs.
Curve(const std::vector< AtomsMath::Vector3f > cvs, unsigned int degree)
Constructor.
AtomsMath::Vector3f tangentOnCurve(float param) const
Get a tangent on the curve.
std::vector< AtomsMath::Vector3f > parallelFrameNormals(unsigned int samples, AtomsMath::Vector3f upVec) const
Get curve normals using parallel frame.
const std::vector< float > & knots() const
Get curve knots.
AtomsMath::Matrixf parallelFrameAtPoint(unsigned int samples, AtomsMath::Vector3f upVec, float param) const
Get curve normal on a point using parallel frame.
AtomsMath::Vector3f pointOnCurve(float param) const
Get a point on the curve.
float maxU() const
Max U value.
std::vector< AtomsMath::Vector3f > curveDerivs(float param, unsigned int nderiv) const
Return the curve derivative.
virtual ~Curve()
Destructor.
int findMult(int r) const
Find multiplicity.
unsigned int degree() const
Get curve degree.
std::vector< std::vector< float > > dersBasis(int knotSpan, float u, unsigned int degree) const
Basis function for B-Spline.
std::vector< float > & knots()
Get curve knots.
Curve()
Constructor.
std::vector< AtomsMath::Vector3f > & cvs()
Get curve cvs.
int findKnot(float u) const
Find span.
void computeUniformKnots()
Compute uniform knots.
virtual std::pair< float, AtomsMath::Vector3f > closestTangent(const AtomsMath::Vector3f &point, unsigned int maxStep=6, unsigned int maxIterations=10, float tollarence=0.0001f)
Get closest tangent.
virtual std::pair< float, AtomsMath::Vector3f > closestPoint(const AtomsMath::Vector3f &point, unsigned int maxStep=6, unsigned int maxIterations=10, float tollarence=0.0001f)
Get closest point.
void setDegree(unsigned int degree)
Set curve degree.
std::vector< float > basis(int knotSpan, float u) const
Basis function for B-Spline.
AtomsCore namespace.
Definition: Base64.h:13