MCPcopy Index your code
hub / github.com/g3n/engine / Volume

Method Volume

geometry/geometry.go:385–404  ·  view source on GitHub ↗

Volume returns the volume. NOTE: This only works for closed triangle-based meshes.

()

Source from the content-addressed store, hash-verified

383// Volume returns the volume.
384// NOTE: This only works for closed triangle-based meshes.
385func (g *Geometry) Volume() float32 {
386
387 // If valid, return its value
388 if g.volumeValid {
389 return g.volume
390 }
391
392 // Reset volume
393 g.volume = 0
394
395 // Calculate volume of all tetrahedrons
396 g.ReadFaces(func(vA, vB, vC math32.Vector3) bool {
397 vA.Sub(&vC)
398 vB.Sub(&vC)
399 g.volume += vC.Dot(vA.Cross(&vB)) / 6.0
400 return false
401 })
402 g.volumeValid = true
403 return g.volume
404}
405
406// RotationalInertia returns the rotational inertia tensor, also known as the moment of inertia.
407// This assumes constant density of 1 (kg/m^2).

Callers

nothing calls this directly

Calls 4

ReadFacesMethod · 0.95
CrossMethod · 0.80
SubMethod · 0.45
DotMethod · 0.45

Tested by

no test coverage detected