MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ generate_rectangle()

MAYAFLUX_API std::vector< glm::vec3 > MayaFlux::Kinesis::generate_rectangle ( const glm::vec3 &  center,
float  width,
float  height,
const glm::vec3 &  normal = glm::vec3(0, 0, 1) 
)

Generate vertices of an axis-aligned rectangular path.

Parameters
centerRectangle centroid
widthExtent along local X axis
heightExtent along local Y axis
normalRectangle plane normal
Returns
5 vertices (closed rectangular path for LINE_STRIP)

Definition at line 138 of file GeometryPrimitives.cpp.

143{
144 glm::vec3 n = glm::normalize(normal);
145 glm::vec3 u;
146
147 if (std::abs(n.z) < 0.9F) {
148 u = glm::normalize(glm::cross(n, glm::vec3(0, 0, 1)));
149 } else {
150 u = glm::normalize(glm::cross(n, glm::vec3(1, 0, 0)));
151 }
152
153 glm::vec3 v = glm::cross(n, u);
154
155 float half_width = width * 0.5F;
156 float half_height = height * 0.5F;
157
158 std::vector<glm::vec3> vertices;
159 vertices.reserve(5);
160
161 vertices.push_back(center - half_width * u - half_height * v);
162
163 vertices.push_back(center + half_width * u - half_height * v);
164
165 vertices.push_back(center + half_width * u + half_height * v);
166
167 vertices.push_back(center - half_width * u + half_height * v);
168
169 vertices.push_back(vertices[0]);
170
171 return vertices;
172}
uint32_t width
uint32_t height

References height, and width.