Marine systems simulation
InitializerTools3DCurve.h
1#pragma once
2#include "eigen_matrix_defs.h"
3#include <vector>
4#include "sfh/cable/catenary.h"
5
6namespace CoRiBoDynamics {
7 namespace Utilities {
8
9
10 /*
11 Interface class for a general curve initalizer for 6-dof elements
12 */
14 public:
15 virtual ~CurveSegment(){};
16 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) = 0;
17 virtual double Length() = 0;
18 vec3 GetStartPoint(){vec3 P; Quat Q; Compute(0,0,P,Q); return P;}
19 vec3 GetEndPoint(){vec3 P; Quat Q; Compute(Length(),0,P,Q); return P;}
20 };
21
22 /*
23 Combines several curve segments in sequence
24 */
26 public:
28 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) override;
29 void AddCurveSegment(CurveSegment* curve_segment);
30 virtual double Length() override;
31 protected:
32 struct segment{ double start_coordinate; double end_coordinate; CurveSegment* curve_segment;};
33 std::vector<segment> m_segments;
34 double m_accumulated_length;
35 };
36
37 /*
38 Straight line curve, starting from point P0, in the direction of the unit vector N
39 */
41 public:
42 StraightSegment(const vec3& P0, const vec3& N, double length);
43 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) override;
44 virtual double Length() override;
45
46 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47 protected:
48 vec3 m_P0;
49 vec3 m_N;
50 Quat m_Q;
51 double m_length;
52 };
53
54 /*
55 Catenary curve from point A to B, with the given length
56 */
58 public:
59 CatenarySegment(const vec3& PA, const vec3& PB, double length);
60 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) override;
61 virtual double Length() override;
62
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64 protected:
65 sfh::cable::Catenary3D m_curve;
66 double m_length;
67 };
68
70 public:
71 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
72 RotatedCatenarySegment(const Quat& Q, const vec3& PA, const vec3& PB, double length);
73 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) override;
74 protected:
75 Quat m_Q;
76 };
77
78 /*
79 CurveSegment implementation that defines a helix curve
80 */
81 class HelixSegment : public CurveSegment{
82 public:
83 HelixSegment(double inner_radius, double curve_radius, double z_offset, double length = std::numeric_limits<double>::max());
84 virtual void Compute(double parameter_coordinate, double element_length, vec3& Position, Quat& Orientation) override;
85 virtual double Length() override;
86
87 void SetOrientation(const vec3& P, const Quat& Q);
88 void SetOrientation(const vec3& P, const Quat& Q, bool right_winding);
89
90 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
91 protected:
92 double m_major_radius;
93 double m_delta;
94 double m_theta_offset;
95 double m_helix_length_factor;
96 vec3 m_P;
97 Quat m_Q;
98 bool m_right_winding;
99 double m_length;
100 };
101
102 /*
103 Defines a circle sector curve with the specified length that intersects point A and B.
104 A and B must have a horizontal distance greater than 0.
105 The circle sector points downwards with gravity.
106 */
108 public:
109 CircleInitCurve(const vec3& PA, const vec3& PB, double Length);
110
111 void Compute(double cable_coordinate, double element_length, vec3& P, Quat& Q);
112 double Length(){return m_Length;}
113
114 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
115 private:
116 static double Length_Function(double D, double H);
117 static double Length_Function_Derivative(double D, double H);
118 double m_Length;
119 Quat m_Q;
120 vec3 m_Center;
121 vec3 m_unit_rotation_axis;
122 vec3 m_rotation_arm;
123 double m_radius;
124 //double m_theta0;
125 Quat m_Q0;
126 };
127 }
128}
Definition: InitializerTools3DCurve.h:57
Definition: InitializerTools3DCurve.h:107
Definition: InitializerTools3DCurve.h:25
Definition: InitializerTools3DCurve.h:13
Definition: InitializerTools3DCurve.h:81
Definition: InitializerTools3DCurve.h:69
Definition: InitializerTools3DCurve.h:40
Definition: CollisionManager.h:6
Definition: InitializerTools3DCurve.h:32