Area returns the surface area. NOTE: This only works for triangle-based meshes.
()
| 359 | // Area returns the surface area. |
| 360 | // NOTE: This only works for triangle-based meshes. |
| 361 | func (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. |
nothing calls this directly
no test coverage detected