MCPcopy
hub / github.com/g3n/engine / Area

Method Area

geometry/geometry.go:361–381  ·  view source on GitHub ↗

Area returns the surface area. NOTE: This only works for triangle-based meshes.

()

Source from the content-addressed store, hash-verified

359// Area returns the surface area.
360// NOTE: This only works for triangle-based meshes.
361func (g *Geometry) Area() float32 {
362
363 // If valid, return its value
364 if g.areaValid {
365 return g.area
366 }
367
368 // Reset area
369 g.area = 0
370
371 // Sum area of all triangles
372 g.ReadFaces(func(vA, vB, vC math32.Vector3) bool {
373 vA.Sub(&vC)
374 vB.Sub(&vC)
375 vC.CrossVectors(&vA, &vB)
376 g.area += vC.Length() / 2.0
377 return false
378 })
379 g.areaValid = true
380 return g.area
381}
382
383// Volume returns the volume.
384// NOTE: This only works for closed triangle-based meshes.

Callers

nothing calls this directly

Calls 4

ReadFacesMethod · 0.95
CrossVectorsMethod · 0.80
SubMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected