Esempio n. 1
0
def sphere():
    minCoord = pgf.var_float(-1.)
    maxCoord = pgf.var_float(1.)
    minpt = pgf.vec3(minCoord, minCoord, minCoord)
    maxpt = pgf.vec3(maxCoord, maxCoord, maxCoord)
    box = pgf.box3(minpt, maxpt)
    npts = pgv.slideri32("Point count", 5, 50, 25)
    cloud = pgf.randomPointsInBox(box, npts)
    pgv.show("Point Cloud", cloud)
    sphere, *_ = pgf.boundingSphere(cloud)
    return sphere
Esempio n. 2
0
def test_cachedOffsetDataRegression():
    # This tests for a regression (lack of) happened while working on PR # 53.
    pt = pgf.var_vec3((0., 0., 0.))
    norm = pgf.var_vec3((0., 0., 1.))
    plane = pgf.plane(pt, norm)
    minpt = pgf.var_vec3((-.5, -.5, 0.))
    maxpt = pgf.var_vec3((.5, .5, 0.))
    box2 = pgf.box2(pgf.var_vec2((-.5, -.5)), pgf.var_vec2((.5, .5)))
    box3 = pgf.box3(minpt, maxpt)
    npts = pgf.var_int(4)
    cloud = pgf.randomPointsInBox(box3, npts)
    edgeLen = pgf.var_float(1)
    rect = pgf.rectangleMesh(plane, box2, edgeLen)
    distances = pgf.distance(pgf.graft(pgf.vertices(rect)), cloud)
    pdists = pgf.read(pgf.flatten(distances))
    assert len(pdists) == 16
Esempio n. 3
0
import pygalfunc as pgf
import pygalview as pgv

minpt = pgf.var_vec3((-1., -1., -1.))
maxpt = pgf.var_vec3((1., 1., 1.))
box = pgf.box3(minpt, maxpt)
npts = pgv.slideri32("Point count", 10, 1000, 100)

cloud = pgf.randomPointsInBox(box, npts)
hull = pgf.convexHullFromPoints(cloud)

pgv.show("Convex Hull", hull)
pgv.show("Points", cloud)
Esempio n. 4
0
import pygalfunc as pgf
import pygalview as pgv

relpath = pgf.var_string("../assets/bunny.obj")
path = pgf.absPath(relpath)
mesh = pgf.loadObjFile(path)
scale = pgf.var_float(10.0)
scaled = pgf.scale(mesh, scale)
box = pgf.bounds(scaled)

npts = pgv.slideri32("Point count", 1000, 25000, 100)
inpts = pgf.randomPointsInBox(box, npts)

outpts = pgf.closestPoints(scaled, inpts)

pgv.show("Box", box)
pgv.show("Mesh", scaled)
pgv.show("Query Points", inpts)
pgv.show("Closest Points", outpts)