ExtruderCone.cpp
Go to the documentation of this file.
2 
4 {
5  /*
6  * Extruder Data:
7  * Update: Dec/08/2015
8  * angle(radians) : angle between generatrix and central axis
9  * height(cm) : length of the central axis
10  * wave_angle : maximal waving angle for rotating orientation
11  * divide : used in Collision Detection Algo. Ver1.0
12  the number of triangle face to approx. the sweeping
13  * cone solid
14  */
15  normal_ = Vec3f(0, 0, 1);
16  angle_ = 30.0 / 180.0 * F_PI;
17  height_ = 20.0;
18  wave_angle_ = F_PI / 18.0;
19  divide_ = 16;
20  tool_lenth_ = 15;// 120mm connect robot arm
21  radii_ = tan(angle_)*height_;
22  cyclinder_height_= 100;//50mm for connection tools on the arm
23 
24  //top_cylin
25  top_cylin_center_lenth_ = 89; //from start point
26  top_cylin_lenth_ = 68;
27  top_cylin_radii_ = 36;
28 
29  GeneCone();
30 }
31 
32 ExtruderCone::ExtruderCone(double height, point base_point, Vec3f normal, double angle)
33 {
34  height_ = height;
35  base_point_ = base_point;
36  normal_ = normal;
37  angle_ = angle;
38 }
39 
41 {
42 
43 }
44 
46 {
47  cout << angle_ << " " << normal_.x() << normal_.z()<<endl;
48 }
49 
51 {
52  vector<Triangle> temp;
53  vector<point> ploy;
54  double radii = tan(angle_)*height_;
55  for (int i = 0; i < divide_; i++)
56  {
58  point v1 = point(radii*cos(2 * F_PI / divide_*(i + 1)), radii*sin(2 * F_PI / divide_*(i + 1)), height_);
59  point v2 = point(radii*cos(2 * F_PI / divide_*(i)), radii*sin(2 * F_PI / divide_*(i)), height_);
60 
61  ploy.push_back(v2);
62  temp.push_back(Triangle(base_point_, v1, v2));
63  }
64  side_ = temp;
65  side_end_ = side_;
66  top_ = ploy;
67 }
68 
69 void ExtruderCone::Render(WireFrame* ptr_frame, double alpha)
70 {
71 
72 // for (int i = 0; i < side_.size(); i++)
73 // {
74 // side_[i].Render(ptr_frame, alpha);
75 // side_end_[i].Render(ptr_frame, alpha);
76 // }
77 //
78 // //render top
79 //
80 // glBegin(GL_POLYGON);
81 // glColor4f(0.5, 0.5, 0.7, alpha);
82 // glNormal3fv(normal_);
83 // for (int i = 0; i < top_.size(); i++)
84 // {
85 // glVertex3fv(ptr_frame->Unify(top_[i]));
86 // }
87 // glEnd();
88 //
89 // glBegin(GL_QUADS);
90 // glColor4f(0.5, 0.5, 0.7, alpha);
91 // for (int i = 0; i < side_.size(); i++)
92 // {
93 // for (int j = 0; j < 3; j++)
94 // {
95 // glVertex3fv(ptr_frame->Unify(side_[i].vert_list_[j]));
96 // glVertex3fv(ptr_frame->Unify(side_end_[i].vert_list_[j]));
97 // glVertex3fv(ptr_frame->Unify(end_));
98 // glVertex3fv(ptr_frame->Unify(start_));
99 // }
100 // }
101 // glEnd();
102 
103 
104 }
105 
107 {
108 
109  if (start.z() >= end.z())
110  {
111  point temp = start;
112  start = end;
113  end = temp;
114  }
115  start_ = start;
116  end_ = end;
117 
118 
119  float a =start.x();
120  float b = start.y();
121  float c = start.z();
123 
124  p.normalize();
125  if (p.getZ() == 1)
126  return;
127 
129  pz.normalize();
131  Geometry::Vector3d zpz = Geometry::cross(z, pz);
132  zpz.normalize();
133  Geometry::Vector3d vec = pz * cos(angle) + z * sin(angle);
134  normal_ = Vec3f(vec.getX(), vec.getY(), vec.getZ());
135 
136  Geometry::Vector3d u = pz*sin(angle) -z*cos(angle);
137 
138  double radii = tan(angle_)*height_;
139 
140  for (int i = 0; i < divide_; i++)
141  {
142 
143  Geometry::Vector3d v1 = vec*height_ + u*(radii*cos(2 * F_PI / divide_*(i + 1))) + zpz*(radii*sin(2 * F_PI / divide_*(i + 1)));
144  point v1_(v1.getX(), v1.getY(), v1.getZ());
145 
146  Geometry::Vector3d v2 = vec*height_ + u*(radii*cos(2 * F_PI / divide_*(i))) + zpz*(radii*sin(2 * F_PI / divide_*(i)));
147  point v2_(v2.getX(), v2.getY(), v2.getZ());
148  top_[i] = v2_;
149  side_[i] = Triangle(base_point_, v1_, v2_);
150  }
151 
152  side_end_ = side_;
153  // Move
154  for (int i = 0; i < side_.size(); i++)
155  {
156  side_[i].Add(end);
157  side_end_[i].Add(start);
158  }
159 
160 
161  for (int i = 0; i < top_.size(); i++)
162  top_[i] += end;
163 }
164 
166 {
167  for (int i = 0; i < temp.vert_list_.size(); i++)
168  {
169  temp.vert_list_[i] = Multi(temp.vert_list_[i]);
170  }
171  temp.Normal_();
172 }
173 
175 {
176 
177  point temp = s;
178  double x = rotate_[0][0] * temp.x() + rotate_[0][1] * temp.y(); +rotate_[0][2] * temp.z() + rotate_[3][0];
179  double y = rotate_[1][0] * temp.x() + rotate_[1][1] * temp.y(); +rotate_[1][2] * temp.z() + rotate_[3][1];
180  double z = rotate_[2][0] * temp.x() + rotate_[2][1] * temp.y(); +rotate_[2][2] * temp.z() + rotate_[3][2];
181 
182  return point(x, y, z);
183 }
184 
185 
187 {
188  normal_ = Vec3f(normal.getX(),normal.getY(),normal.getZ());
189 
190 
191 
192  if (start.z() >= end.z())
193  {
194  point temp = start;
195  start = end;
196  end = temp;
197  }
198  start_ = start;
199  end_ = end;
200 
201 
202  float a = start.x();
203  float b = start.y();
204  float c = start.z();
206 
207  p.normalize();
208 
209  if (Geometry::dot(p, normal) > 0.001)
210  return;
211 
212 
213  if (p.getZ() == 1)
214  {
215  normal = GeoV3(0, 0, 1);
216  Geometry::Vector3d pz = Geometry::cross(p, normal);
217  pz.normalize();
220  double radii = tan(angle_)*height_;
221 
222  for (int i = 0; i < divide_; i++)
223  {
225  + u*(radii*cos(2 * F_PI / divide_*(i + 1))) + v*(radii*sin(2 * F_PI / divide_*(i + 1)));
226  point v1_(v1.getX(), v1.getY(), v1.getZ());
227 
229  + u*(radii*cos(2 * F_PI / divide_*(i))) + v*(radii*sin(2 * F_PI / divide_*(i)));
230  point v2_(v2.getX(), v2.getY(), v2.getZ());
231  top_[i] = v2_;
232 
233  side_[i] = Triangle(base_point_, v1_, v2_);
234  }
235  side_end_ = side_;
236  // Move
237  for (int i = 0; i < side_.size(); i++)
238  {
239  side_[i].Add(end);
240  side_end_[i].Add(start);
241  }
242  for (int i = 0; i < top_.size(); i++)
243  top_[i] += end;
244  }
245  else
246  {
247  Geometry::Vector3d pz = Geometry::cross(p, normal);
248  pz.normalize();
249  Geometry::Vector3d u = p;
250  Geometry::Vector3d v = pz;
251  double radii = tan(angle_)*height_;
252  for (int i = 0; i < divide_; i++)
253  {
255  + u*(radii*cos(2 * F_PI / divide_*(i + 1))) + v*(radii*sin(2 * F_PI / divide_*(i + 1)));
256  point v1_(v1.getX(), v1.getY(), v1.getZ());
257 
259  + u*(radii*cos(2 * F_PI / divide_*(i))) + v*(radii*sin(2 * F_PI / divide_*(i)));
260  point v2_(v2.getX(), v2.getY(), v2.getZ());
261 
262  top_[i] = v2_;
263 
264  side_[i] = Triangle(base_point_, v1_, v2_);
265  }
266  side_end_ = side_;
267  // Move
268  for (int i = 0; i < side_.size(); i++)
269  {
270  side_[i].Add(end);
271  side_end_[i].Add(start);
272  }
273  for (int i = 0; i < top_.size(); i++)
274  top_[i] += end;
275  }
276 }
double wave_angle_
Definition: ExtruderCone.h:104
GLfloat GLfloat GLfloat alpha
trimesh::vec3 Vec3f
Definition: WireFrame.h:52
double top_cylin_center_lenth_
Definition: ExtruderCone.h:119
trimesh::point point
Definition: WireFrame.h:51
double getY()
Definition: Geometry.h:91
GLuint start
static double angle(Vector3d vec1, Vector3d vec2)
Definition: Geometry.h:158
vector< point > vert_list_
Definition: Polyface.h:109
void RotateTri(Triangle temp)
GLfloat GLfloat v1
GLfloat angle
point base_point_
Definition: ExtruderCone.h:106
reference x()
Definition: Vec.h:194
void Rotation(double angle, point start, point end)
GLint GLenum GLint x
GLboolean GLboolean GLboolean GLboolean a
vector< Triangle > side_end_
Definition: ExtruderCone.h:111
double top_cylin_radii_
Definition: ExtruderCone.h:121
const GLubyte * c
void Normal_()
Definition: Polyface.h:94
GLuint GLuint end
#define F_PI
Definition: GCommon.h:54
double cyclinder_height_
Definition: ExtruderCone.h:102
double angle_
Definition: ExtruderCone.h:98
reference y()
Definition: Vec.h:203
GLfloat v0
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean b
double height_
Definition: ExtruderCone.h:99
GLdouble GLdouble GLdouble z
double getX()
Definition: Geometry.h:90
const GLdouble * v
double getZ()
Definition: Geometry.h:92
GLdouble s
GLfloat GLfloat GLfloat v2
Vec< 3, float > vec
Definition: Vec.h:545
static double dot(Vector3d vec1, Vector3d vec2)
Definition: Geometry.h:151
float rotate_[4][4]
Definition: ExtruderCone.h:115
double top_cylin_lenth_
Definition: ExtruderCone.h:120
vector< point > top_
Definition: ExtruderCone.h:112
reference z()
Definition: Vec.h:212
static Vector3d cross(Vector3d vec1, Vector3d vec2)
Definition: Geometry.h:143
GLfloat GLfloat p
Geometry::Vector3d GeoV3
Definition: Polyface.h:51
vector< Triangle > side_
Definition: ExtruderCone.h:105
GLint y
void Render(WireFrame *ptr_frame, double alpha)
double tool_lenth_
Definition: ExtruderCone.h:100
point Multi(point s)


choreo_task_sequence_planner
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:03:14