Commit 8495a970270ff4fc04982ab2b510408f9a1b5cf3
1 parent
bf23ee36
added comments to cylinder
Showing
1 changed file
with
30 additions
and
6 deletions
Show diff stats
stim/visualization/cylinder.h
... | ... | @@ -11,22 +11,26 @@ template<typename T> |
11 | 11 | class cylinder |
12 | 12 | { |
13 | 13 | private: |
14 | - stim::circle<T> s; | |
15 | - std::vector< stim::vec<T> > pos; | |
16 | - std::vector< stim::vec<T> > mags; | |
17 | - std::vector< T > L; | |
14 | + stim::circle<T> s; //an arbitrary circle | |
15 | + std::vector< stim::vec<T> > pos; //positions of the cylinder. | |
16 | + std::vector< stim::vec<T> > mags; //radii at each position | |
17 | + std::vector< T > L; //length of the cylinder at each position. | |
18 | 18 | |
19 | + ///default init | |
19 | 20 | void |
20 | 21 | init() |
21 | 22 | { |
22 | 23 | |
23 | 24 | } |
24 | 25 | |
26 | + ///inits the cylinder from a list of points (inP) and radii (inM) | |
25 | 27 | void |
26 | 28 | init(std::vector<stim::vec<T> > inP, std::vector<stim::vec<T> > inM) |
27 | 29 | { |
28 | 30 | pos = inP; |
29 | 31 | mags = inM; |
32 | + | |
33 | + //calculate each L. | |
30 | 34 | L.resize(pos.size()-1); |
31 | 35 | T temp = (T)0; |
32 | 36 | for(int i = 0; i < L.size()-1; i++) |
... | ... | @@ -36,6 +40,7 @@ class cylinder |
36 | 40 | } |
37 | 41 | } |
38 | 42 | |
43 | + ///returns the direction vector at point idx. | |
39 | 44 | stim::vec<T> |
40 | 45 | d(int idx) |
41 | 46 | { |
... | ... | @@ -43,6 +48,7 @@ class cylinder |
43 | 48 | |
44 | 49 | } |
45 | 50 | |
51 | + ///returns the total length of the line at index j. | |
46 | 52 | T |
47 | 53 | getl(int j) |
48 | 54 | { |
... | ... | @@ -53,6 +59,8 @@ class cylinder |
53 | 59 | } |
54 | 60 | } |
55 | 61 | |
62 | + ///finds the index of the point closest to the length l on the lower bound. | |
63 | + ///binary search. | |
56 | 64 | int |
57 | 65 | findIdx(T l) |
58 | 66 | { |
... | ... | @@ -76,13 +84,13 @@ class cylinder |
76 | 84 | } |
77 | 85 | |
78 | 86 | public: |
87 | + ///default constructor | |
79 | 88 | cylinder() |
80 | 89 | { |
81 | 90 | |
82 | 91 | } |
83 | 92 | |
84 | 93 | ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder. |
85 | - ///The higher the number of sides, the more rectangeles compose the surface of the cylinder. | |
86 | 94 | ///@param inP: Vector of stim vecs composing the points of the centerline. |
87 | 95 | ///@param inM: Vector of stim vecs composing the radii of the centerline. |
88 | 96 | cylinder(std::vector<stim::vec<T> > inP, std::vector<stim::vec<T> > inM) |
... | ... | @@ -92,6 +100,8 @@ class cylinder |
92 | 100 | |
93 | 101 | |
94 | 102 | ///Returns a position vector at the given p-value (p value ranges from 0 to 1). |
103 | + ///interpolates the position along the line. | |
104 | + ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). | |
95 | 105 | stim::vec<T> |
96 | 106 | p(T pvalue) |
97 | 107 | { |
... | ... | @@ -102,6 +112,10 @@ class cylinder |
102 | 112 | return (pos[idx] + (pos[idx+1]-pos[idx])*((l-L[idx])/(L[idx+1]- L[idx]))); |
103 | 113 | } |
104 | 114 | |
115 | + ///Returns a position vector at the given length into the fiber (based on the pvalue). | |
116 | + ///Interpolates the radius along the line. | |
117 | + ///@param l: the location of the in the cylinder. | |
118 | + ///@param idx: integer location of the point closest to l but prior to it. | |
105 | 119 | stim::vec<T> |
106 | 120 | p(T l, int idx) |
107 | 121 | { |
... | ... | @@ -109,6 +123,8 @@ class cylinder |
109 | 123 | } |
110 | 124 | |
111 | 125 | ///Returns a radius at the given p-value (p value ranges from 0 to 1). |
126 | + ///interpolates the radius along the line. | |
127 | + ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). | |
112 | 128 | T |
113 | 129 | r(T pvalue) |
114 | 130 | { |
... | ... | @@ -119,6 +135,10 @@ class cylinder |
119 | 135 | return (mags[idx] + (mags[idx+1]-mags[idx])*((l-L[idx])/(L[idx+1]- L[idx]))); |
120 | 136 | } |
121 | 137 | |
138 | + ///Returns a radius at the given length into the fiber (based on the pvalue). | |
139 | + ///Interpolates the position along the line. | |
140 | + ///@param l: the location of the in the cylinder. | |
141 | + ///@param idx: integer location of the point closest to l but prior to it. | |
122 | 142 | T |
123 | 143 | r(T l, int idx) |
124 | 144 | { |
... | ... | @@ -127,7 +147,9 @@ class cylinder |
127 | 147 | |
128 | 148 | |
129 | 149 | ///returns the position of the point with a given pvalue and theta on the surface |
130 | - ///in x, y, z coordinates. Theta is in degrees from 0 to 360 | |
150 | + ///in x, y, z coordinates. Theta is in degrees from 0 to 360. | |
151 | + ///@param pvalue: the location of the in the cylinder, from 0 (beginning to 1). | |
152 | + ///@param theta: the angle to the point of a circle. | |
131 | 153 | stim::vec<T> |
132 | 154 | surf(T pvalue, T theta) |
133 | 155 | { |
... | ... | @@ -142,6 +164,8 @@ class cylinder |
142 | 164 | return(s.p(theta)); |
143 | 165 | } |
144 | 166 | |
167 | + ///returns a vector of points necessary to create a circle at every position in the fiber. | |
168 | + ///@param sides: the number of sides of each circle. | |
145 | 169 | std::vector<std::vector<vec<T> > > |
146 | 170 | getPoints(int sides) |
147 | 171 | { | ... | ... |