Atoms Crowd  4.1.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 
AtomsUtils::Curve::tangentOnCurve
AtomsMath::Vector3f tangentOnCurve(float param) const
Get a tangent on the curve.
AtomsUtils::Curve::parallelFrameNormals
std::vector< AtomsMath::Vector3f > parallelFrameNormals(unsigned int samples, AtomsMath::Vector3f upVec) const
Get curve normals using parallel frame.
AtomsUtils
AtomsCore namespace.
Definition: Base64.h:13
AtomsUtils::Curve::setDegree
void setDegree(unsigned int degree)
Set curve degree.
AtomsUtils::Curve::knots
const std::vector< float > & knots() const
Get curve knots.
AtomsUtils::Curve::computeUniformKnots
void computeUniformKnots()
Compute uniform knots.
AtomsUtils::Curve::Curve
Curve(const std::vector< AtomsMath::Vector3f > cvs, unsigned int degree)
Constructor.
AtomsUtils::Curve::findKnot
int findKnot(float u) const
Find span.
AtomsUtils::Curve::knots
std::vector< float > & knots()
Get curve knots.
AtomsUtils::Curve::findSpan
int findSpan(float u) const
Find span.
AtomsUtils::Curve::Curve
Curve()
Constructor.
AtomsUtils::Curve
Nurbs curve.
Definition: Curve.h:18
AtomsUtils::Curve::pointOnCurve
AtomsMath::Vector3f pointOnCurve(float param) const
Get a point on the curve.
AtomsUtils::Curve::~Curve
virtual ~Curve()
Destructor.
AtomsUtils::Curve::dersBasis
std::vector< std::vector< float > > dersBasis(int knotSpan, float u, unsigned int degree) const
Basis function for B-Spline.
AtomsUtils::Curve::closestTangent
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.
AtomsUtils::Curve::closestPoint
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.
AtomsUtils::Curve::basis
std::vector< float > basis(int knotSpan, float u) const
Basis function for B-Spline.
AtomsUtils::Curve::parallelFrameAtPoint
AtomsMath::Matrixf parallelFrameAtPoint(unsigned int samples, AtomsMath::Vector3f upVec, float param) const
Get curve normal on a point using parallel frame.
AtomsUtils::Curve::cvs
const std::vector< AtomsMath::Vector3f > & cvs() const
Ge curve cvs.
AtomsUtils::Curve::operator=
const Curve & operator=(const Curve &curve)
Assign operator.
AtomsUtils::Curve::cvs
std::vector< AtomsMath::Vector3f > & cvs()
Get curve cvs.
AtomsUtils::Curve::findMult
int findMult(int r) const
Find multiplicity.
AtomsUtils::Curve::degree
unsigned int degree() const
Get curve degree.
AtomsUtils::Curve::curveDerivs
std::vector< AtomsMath::Vector3f > curveDerivs(float param, unsigned int nderiv) const
Return the curve derivative.
AtomsUtils::Curve::maxU
float maxU() const
Max U value.