Example #1
0
import pygalfunc as pgf
import pygalview as pgv

minpt = pgf.var_vec3((-1., -1., 0.))
maxpt = pgf.var_vec3((1., 1., 0.))
box = pgf.box3(minpt, maxpt)

npts = pgv.slideri32("Point count", 10, 1000, 25)

cloud = pgf.randomPointsInBox(box, npts)
circ, center, radius = pgf.boundingCircle(cloud)

pgv.show("cloud", pgf.pointCloud3d(cloud))
pgv.show("circ", circ)
pgv.print("Center", center)
pgv.print("Radius", radius)

pgv.runCommands("2d")
Example #2
0
import pygalfunc as pgf
import pygalview as pgv

POINTS = [
    (0, 0, 0),
    (1, 0, 0),
    (1, 1, 0),
    (-.3, 1, 0),
    (0, -1, 0),
]

pts = pgf.var_vec3(POINTS)
nums = pgf.toString(pgf.series(pgf.var_int(0), pgf.var_int(1), pgf.listLength(pts)))
idxPt = pgf.listItem(pts, pgv.slideri32("Index", 0, len(POINTS) - 1, 0))
circ, *_ = pgf.boundingCircle(pts)

pgv.show("indices", pgv.tags(nums, pts))
pgv.show("circle", circ)
pgv.show("points", pts)
pgv.print("Point at index", idxPt)
Example #3
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 = pgv.slideri32("Point count", 5, 50, 25)
cloud = pgf.randomPointsInBox(box3, npts)

edgeLen = pgf.var_float(.01)
rect = pgf.rectangleMesh(plane, box2, edgeLen)

distances = pgf.distance(pgf.graft(pgf.vertices(rect)), cloud)
sortedDists = pgf.sort(distances, distances)
maxDist = pgf.listItem(sortedDists, pgf.sub(pgf.listLength(sortedDists), pgf.var_int(1)))

scheme = pgf.var_vec3([
    (0., 0., 1.),
    (0., 1., 0.),
    (1., 1., 0.),
    (1., 0., 0.)
])
colors = pgf.mapValueToColor(maxDist, pgf.var_vec2((.5, 1.2)), scheme)
colored = pgf.meshWithVertexColors(rect, colors)

circ, *_ = pgf.boundingCircle(cloud)

# pgv.show("rectangle", rect)
pgv.show("cloud", cloud)
pgv.show("colored", colored)
pgv.show("circle", circ)

pgv.runCommands("2d")
Example #4
0
    (1, 1, 0),
    (-.3, 1, 0),
    (0, -1, 0),
]

GLYPHDATA = [
    "/home/rnjth94/works/YouTube/GAL_BoundingCircle/receiverDishGlyph.png",
    "/home/rnjth94/works/YouTube/GAL_BoundingCircle/transmitterGlyph.png"
]


def initGlyphs():
    return pgv.loadGlyphs(GLYPHDATA)


if __name__ == "__main__":
    glyphs = initGlyphs()
    pts = pgf.var_vec3(POINTS)
    cloudGlyphs = pgf.var_int([glyphs[0] for _ in range(len(POINTS))])
    idxPt = pgf.listItem(pts, pgv.slideri32("Index", 0, len(POINTS) - 1, 0))
    circ, center, radius = pgf.boundingCircle(pts)
    center3 = pgf.vec3FromVec2(center)
    centerGlyph = pgf.var_int(glyphs[1])

    pgv.show("glyph1", pgv.glyphs(cloudGlyphs, pts))
    pgv.show("glyph2", pgv.glyphs(centerGlyph, center3))
    pgv.show("circle", circ)
    pgv.show("points", pts)
    pgv.show("center", center3)
    pgv.print("Point at index", idxPt)