MCPcopy
hub / github.com/fogleman/ln / FitInside

Method FitInside

ln/mesh.go:60–68  ·  view source on GitHub ↗
(box Box, anchor Vector)

Source from the content-addressed store, hash-verified

58}
59
60func (m *Mesh) FitInside(box Box, anchor Vector) {
61 scale := box.Size().Div(m.BoundingBox().Size()).MinComponent()
62 extra := box.Size().Sub(m.BoundingBox().Size().MulScalar(scale))
63 matrix := Identity()
64 matrix = matrix.Translate(m.BoundingBox().Min.MulScalar(-1))
65 matrix = matrix.Scale(Vector{scale, scale, scale})
66 matrix = matrix.Translate(box.Min.Add(extra.Mul(anchor)))
67 m.Transform(matrix)
68}
69
70func (m *Mesh) Transform(matrix Matrix) {
71 for _, t := range m.Triangles {

Callers 4

UnitCubeMethod · 0.95
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 12

BoundingBoxMethod · 0.95
TransformMethod · 0.95
IdentityFunction · 0.85
MinComponentMethod · 0.80
DivMethod · 0.80
SizeMethod · 0.80
SubMethod · 0.80
MulScalarMethod · 0.80
TranslateMethod · 0.80
ScaleMethod · 0.80
AddMethod · 0.45
MulMethod · 0.45

Tested by

no test coverage detected