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

◆ generate_rectangle()

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 100 of file GeometryPrimitives.cpp.

105{
106 glm::vec3 n = glm::normalize(normal);
107 glm::vec3 u;
108
109 if (std::abs(n.z) < 0.9F) {
110 u = glm::normalize(glm::cross(n, glm::vec3(0, 0, 1)));
111 } else {
112 u = glm::normalize(glm::cross(n, glm::vec3(1, 0, 0)));
113 }
114
115 glm::vec3 v = glm::cross(n, u);
116
117 float half_width = width * 0.5F;
118 float half_height = height * 0.5F;
119
120 std::vector<glm::vec3> vertices;
121 vertices.reserve(5);
122
123 vertices.push_back(center - half_width * u - half_height * v);
124
125 vertices.push_back(center + half_width * u - half_height * v);
126
127 vertices.push_back(center + half_width * u + half_height * v);
128
129 vertices.push_back(center - half_width * u + half_height * v);
130
131 vertices.push_back(vertices[0]);
132
133 return vertices;
134}
uint32_t width

References width.