MCPcopy Create free account
hub / github.com/GeometryCollective/ddg-exercises / normalize

Method normalize

core/src/geometry.cpp:314–337  ·  view source on GitHub ↗

* Centers a mesh about the origin. * Also rescales the mesh to unit radius if == true. */

Source from the content-addressed store, hash-verified

312 * Also rescales the mesh to unit radius if <rescale> == true.
313 */
314void VertexPositionGeometry::normalize(const Vector3& origin, bool rescale) {
315
316 // Compute center of mass.
317 Vector3 center = centerOfMass();
318
319 // Translate to origin [of original mesh].
320 double radius = 0;
321 for (Vertex v : mesh.vertices()) {
322 inputVertexPositions[v] -= center;
323 radius = std::max(radius, inputVertexPositions[v].norm());
324 }
325
326 // Rescale.
327 if (rescale) {
328 for (Vertex v : mesh.vertices()) {
329 inputVertexPositions[v] /= radius;
330 }
331 }
332
333 // Translate to origin [of original mesh].
334 for (Vertex v : mesh.vertices()) {
335 inputVertexPositions[v] += origin;
336 }
337}
338
339} // namespace surface
340} // namespace geometrycentral

Callers 8

transportNoRotationMethod · 0.80
updateDirectionFieldFunction · 0.80
generateRandomOneFormFunction · 0.80
functionCallbackFunction · 0.80
mainFunction · 0.80
TEST_FFunction · 0.80
functionCallbackFunction · 0.80

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.64