Skip to main content

Polyhedron

Client Server

A polyhedron is built from half-spaces. Each half-space is defined by a plane (a point + a normal) and represents “everything on one side of that plane.”

function self:examplePolyhedron(pos)
local dirs = {
Vec3( 1, 0, 0),
Vec3(-1, 0, 0),
Vec3( 0, 1, 0),
Vec3( 0, 0, 1)
}

local sides = {}
for _, n in ipairs(dirs) do
local pl = Vec4()
pl:MakePlane(pos + n, n)
table.insert(sides, pl)
end

local sh = Polyhedron()
sh.sides = sides
return sh
end

Constructors​

Polyhedron Polyhedron()​

Polyhedron Polyhedron(Vec4[] sides)​

Methods​

Vec4 side GetSide(integer index)​

nil SetSide(integer index, Vec4 side)​

nil AddPlane(number px, number py, number pz, number nx, number ny, number nz)​

boolean valid, string error IsValid()​

Polyhedron Transform(Vec3 pos, Quat rot, number scale)​

Returns a new polyhedron transformed by position, rotation, and uniform scale; the original instance is left unchanged.

Properties​

Vec3 pos​

Vec4[] sides​

the half spaces that make up the polyhedron. Use Vec4:MakePlane(pos, normal) to create a plane.

integer sidesCount​