Skip to content

Book 2.8: Optional simplification of box() face construction #1733

@xiaodoliu

Description

@xiaodoliu

The box() helper constructs the six faces of the box by explicitly recombining coordinates, for example:

point3(min.x(), min.y(), max.z())

However, since the function already computes the axis-aligned edge vectors dx, dy, and dz, the six faces can alternatively be constructed symmetrically using only min, max, and these edge vectors:

sides->add(make_shared<quad>(min, dx, dy, mat)); // back
sides->add(make_shared<quad>(min, dx, dz, mat)); // bottom
sides->add(make_shared<quad>(min, dy, dz, mat)); // left
sides->add(make_shared<quad>(max, -dx, -dy, mat)); // front
sides->add(make_shared<quad>(max, -dx, -dz, mat)); // top
sides->add(make_shared<quad>(max, -dy, -dz, mat)); // right

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions