forked from uyras/partsEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hc_flower.cpp
88 lines (68 loc) · 2.46 KB
/
hc_flower.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "hc_flower.h"
HC_Flower::HC_Flower()
{
}
void HC_Flower::dropSymmetricLattice(double l, Vect size)
{
this->clear();
totalSize=size*l;
// double p[][2]={
// {l/2., 0},
// {l/4., l*sqrt(3)/4.},
// {l*3/4., l*sqrt(3)/4.}
// };
// double m[][2]={
// {1,0},
// {1/2., sqrt(3)/2.},
// {1/2., -sqrt(3)/2.}
// };
double lx=size.x;
double q3=sqrt(3.);
double mx05=0.5;
double mx075=sqrt(0.75);
for(int vert=0;vert<2*size.x;vert++){
if(vert<size.x){
for(int horiz=0;horiz<(2*size.x+2*vert);horiz++){
Part *temp = new Part();
temp->pos=Vect(0.25*sqrt(3.)*l+l*q3/4+l*q3/2.*horiz-l*vert*q3*0.5,-0.75*l+vert*l*1.5,0);
if(horiz%2==0)
temp->m=Vect(-mx075,mx05,0);
else
temp->m=Vect(mx075,mx05,0);
this->add(temp);
}
}
else{
for(int horiz=0;horiz<(2*size.x-vert+(size.x-2))*2+2;horiz++){
Part *temp = new Part();
temp->pos=Vect(0.25*sqrt(3.)*l+l*q3/4-(size.x-1)*q3/2.*l+l*(vert-(size.x-1))*0.5*q3+l*horiz*q3/2-l*q3*0.5,-0.75*l+vert*l*1.5,0);
if(horiz%2==0)
temp->m=Vect(mx075,mx05,0);
else
temp->m=Vect(-mx075,mx05,0);
this->add(temp);
//center_of_circle.push_back(0-(size.x-1)*sqrt(3)/2.+(vert-(size.x-1))*0.5*sqrt(3)+horiz*q3);
//center_of_circle.push_back(1.5*vert);
}
}
}
for(int vert=0;vert<2*size.x-1;vert++){
if(vert<size.x){
for(int horiz=0;horiz<(size.x+vert+1);horiz++){
Part *temp = new Part();
temp->pos=Vect(0.25*sqrt(3.)*l+l*q3*horiz-l*vert*q3*0.5,vert*l*1.5,0);
temp->m=Vect(0,1,0);
this->add(temp);
}
}
else{
for(int horiz=0;horiz<2*size.x-vert+(size.x-2)+1;horiz++){
Part *temp = new Part();
temp->pos=Vect(0.25*sqrt(3.)*l-(size.x-1)*q3/2.*l+l*(vert-(size.x-1))*0.5*q3+l*horiz*q3,vert*l*1.5,0);
temp->m=Vect(0,1,0);
this->add(temp);
}
}
}
this->setInteractionRange(0);//this->setInteractionRange(1.8); //this->setInteractionRange(l/sqrt(8)*1.05);
}