26aee9ed
Pavel Govyadinov
changed circle cl...
|
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
///create a rectangle given a size and position in Z space.
///@param size: size of the rectangle in ND space.
///@param z_pos z coordinate of the rectangle.
CUDA_CALLABLE
circle(T size, T z_pos = (T)0) : plane<T>()
{
init();
center(stim::vec<T>(0,0,z_pos));
scale(size);
}
///create a rectangle from a center point, normal
///@param c: x,y,z location of the center.
///@param n: x,y,z direction of the normal.
CUDA_CALLABLE
circle(vec<T> c, vec<T> n = vec<T>(0,0,1)) : plane<T>()
{
center(c);
normal(n);
init();
}
///create a rectangle from a center point, normal, and size
///@param c: x,y,z location of the center.
///@param s: size of the rectangle.
///@param n: x,y,z direction of the normal.
CUDA_CALLABLE
circle(vec<T> c, T s, vec<T> n = vec<T>(0,0,1)) : plane<T>()
{
init();
center(c);
rotate(n, U, Y);
scale(s);
}
///create a rectangle from a center point, normal, and size
///@param c: x,y,z location of the center.
///@param s: size of the rectangle.
///@param n: x,y,z direction of the normal.
///@param u: x,y,z direction for the zero vector (from where the rotation starts)
CUDA_CALLABLE
circle(vec<T> c, T s, vec<T> n = vec<T>(0,0,1), vec<T> u = vec<T>(1, 0, 0)) : plane<T>()
{
init();
setU(u);
center(c);
normal(n);
scale(s);
}
///scales the circle by a certain factor
///@param factor: the factor by which the dimensions of the shape are scaled.
CUDA_CALLABLE
void scale(T factor)
{
U *= factor;
Y *= factor;
}
///sets the normal for the cirlce
///@param n: x,y,z direction of the normal.
CUDA_CALLABLE void
normal(vec<T> n)
{
rotate(n, Y);
}
|
26aee9ed
Pavel Govyadinov
changed circle cl...
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
///sets the center of the circle.
///@param n: x,y,z location of the center.
CUDA_CALLABLE T
center(vec<T> p)
{
this->P = p;
}
///boolean comparison
bool
operator==(const circle<T> & rhs)
{
if(P == rhs.P && U == rhs.U && Y == rhs.Y)
return true;
else
return false;
}
///get the world space value given the planar coordinates a, b in [0, 1]
CUDA_CALLABLE stim::vec<T> p(T a, T b)
{
stim::vec<T> result;
vec<T> A = this->P - this->U * (T)0.5 - Y * (T)0.5;
result = A + this->U * a + Y * b;
return result;
}
///parenthesis operator returns the world space given rectangular coordinates a and b in [0 1]
CUDA_CALLABLE stim::vec<T> operator()(T a, T b)
{
return p(a,b);
}
///returns a vector with the points on the initialized circle.
///connecting the points results in a circle.
///@param n: integer for the number of points representing the circle.
std::vector<stim::vec<T> >
getPoints(int n)
{
std::vector<stim::vec<T> > result;
stim::vec<T> point;
T x,y;
float step = 360.0/(float) n;
for(float j = 0; j <= 360.0; j += step)
|