Пример #1
0
def register_artists():
    Artist.register(Point, PointArtist, context='Plotter')
    Artist.register(Vector, VectorArtist, context='Plotter')
    Artist.register(Line, LineArtist, context='Plotter')
    Artist.register(Polyline, PolylineArtist, context='Plotter')
    Artist.register(Polygon, PolygonArtist, context='Plotter')
    Artist.register(Circle, CircleArtist, context='Plotter')
    Artist.register(Ellipse, EllipseArtist, context='Plotter')
    Artist.register(Mesh, MeshArtist, context='Plotter')
    Artist.register(Network, NetworkArtist, context='Plotter')
Пример #2
0
from compas.geometry import Point
from compas.geometry import Polyline
from compas.geometry import NurbsCurve
from compas.artists import Artist
from compas.colors import Color


points = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)]

curve = NurbsCurve.from_points(points)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(curve).draw(color=Color.green())
Artist(Polyline(curve.points)).draw(show_points=True)

Artist.redraw()
Пример #3
0
    for j, (u, v) in enumerate(zip(U, V)):
        if i == 0 or i == 5 or j == 0 or j == 8:
            z = 0.0
        elif i < 2 or i > 3:
            z = -1.0
        else:
            if j < 2 or j > 6:
                z = -1.0
            else:
                z = Z
        row.append(Point(u, v, z))
    points.append(row)

surface = NurbsSurface.from_points(points=points)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

for row in surface.points:
    Artist(Polyline(row)).draw()

for col in zip(*list(surface.points)):
    Artist(Polyline(col)).draw()

Artist(surface).draw()

Artist.redraw()
Пример #4
0
from compas.geometry import Point
from compas.geometry import Line
from compas.geometry import NurbsCurve
from compas.artists import Artist
from compas.colors import Color

line = Line(Point(0, 0, 0), Point(3, 3, 0))
curve = NurbsCurve.from_line(line)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(curve).draw(color=Color.green())

for point in curve.points:
    Artist(point).draw()

Artist.redraw()
Пример #5
0
def register_artists():
    Artist.register(Box, BoxArtist, context='Grasshopper')
    Artist.register(Capsule, CapsuleArtist, context='Grasshopper')
    Artist.register(Circle, CircleArtist, context='Grasshopper')
    Artist.register(Cone, ConeArtist, context='Grasshopper')
    Artist.register(Curve, CurveArtist, context='Grasshopper')
    Artist.register(Cylinder, CylinderArtist, context='Grasshopper')
    Artist.register(Frame, FrameArtist, context='Grasshopper')
    Artist.register(Line, LineArtist, context='Grasshopper')
    Artist.register(Mesh, MeshArtist, context='Grasshopper')
    Artist.register(Network, NetworkArtist, context='Grasshopper')
    Artist.register(Point, PointArtist, context='Grasshopper')
    Artist.register(Polygon, PolygonArtist, context='Grasshopper')
    Artist.register(Polyhedron, PolyhedronArtist, context='Grasshopper')
    Artist.register(Polyline, PolylineArtist, context='Grasshopper')
    Artist.register(RobotModel, RobotModelArtist, context='Grasshopper')
    Artist.register(Sphere, SphereArtist, context='Grasshopper')
    Artist.register(Surface, SurfaceArtist, context='Grasshopper')
    Artist.register(Torus, TorusArtist, context='Grasshopper')
    Artist.register(Vector, VectorArtist, context='Grasshopper')
    Artist.register(VolMesh, VolMeshArtist, context='Grasshopper')
    print('GH Artists registered.')
Пример #6
0
    multiplicities=[1, 1, 1, 1, 1, 1, 1, 1],
    degree=3)

# curve6 = NurbsCurve.from_parameters(
#     points=points,
#     weights=[1.0, 1.0, 1.0, 1.0],
#     knots=[0.0, 0.5, 1.0],
#     multiplicities=[3, 1, 3],
#     degree=2
# )

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(Polyline(bezier.points)).draw()
Artist(Polyline(bezier.locus())).draw()

Artist(Polyline(curve1.points)).draw(show_points=True)

color = Color.red()

Artist(curve1).draw(color=color)
Artist(curve2).draw(color=color.lightened(factor=20))
Artist(curve3).draw(color=color.lightened(factor=40))
Artist(curve4).draw(color=color.lightened(factor=60))
Artist(curve5).draw(color=color.lightened(factor=80))
# Artist(curve6).draw(color=color.lightened(factor=50))
Пример #7
0
# ==============================================================================
# JSON Data
# ==============================================================================

string = surface.to_jsonstring(pretty=True)

print(string)

other = NurbsSurface.from_jsonstring(string)

# print(surface == other)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

u = surface.u_isocurve(0.5 * sum(surface.u_domain))
v = surface.v_isocurve(0.5 * sum(surface.v_domain))

Artist(Polyline(u.locus())).draw()
Artist(Polyline(v.locus())).draw()

# for curve in surface.boundary():
#     Artist(Polyline(curve.locus())).draw()

Artist(other).draw()

Artist.redraw()
Пример #8
0
                                    degree=2)

curve2 = NurbsCurve.from_parameters(points=points,
                                    weights=[1.0, 2.0, 1.0],
                                    knots=[0.0, 1.0],
                                    multiplicities=[3, 3],
                                    degree=2)

curve3 = NurbsCurve.from_parameters(points=points,
                                    weights=[1.0, 1.0, 1.0],
                                    knots=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0],
                                    multiplicities=[1, 1, 1, 1, 1, 1],
                                    degree=2)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(Polyline(bezier.points)).draw()
Artist(Polyline(bezier.locus())).draw(show_points=True)

Artist(Polyline(curve1.points)).draw(show_points=True)

Artist(curve1).draw(color=Color.black())
Artist(curve2).draw(color=Color.pink())
Artist(curve3).draw(color=Color.azure())

Artist.redraw()
Пример #9
0
 def register_artists():
     Artist.register(ReachabilityMap, ReachabilityMapArtist, context='Grasshopper')
Пример #10
0
 def register_artists():
     Artist.register(ReachabilityMap,
                     ReachabilityMapArtist,
                     context='Rhino')
Пример #11
0
head_link = model.add_link('head', visual_meshes=[head, beak])
neck_joint_origin = Frame([0, 0, 4], [1, 0, 0], [0, 1, 0])
model.add_joint('neck_joint',
                Joint.FIXED,
                torso_link,
                head_link,
                origin=neck_joint_origin)

tail = Sphere([0, 0, 0], 1)
tail_link = model.add_link('tail', visual_meshes=[tail])
tail_joint_origin = Frame([0, 0, -4], [1, 0, 0], [0, 1, 0])
model.add_joint('tail_joint',
                Joint.FIXED,
                torso_link,
                tail_link,
                origin=tail_joint_origin)

hat = Cylinder(Circle(Plane([0, 0, 0], [0, 0, 1]), .8), 1.5)
brim = Cylinder(Circle(Plane([0, 0, -1.5 / 2], [0, 0, 1]), 1.4), .1)
hat_link = model.add_link('hat', visual_meshes=[hat, brim])
hat_joint_origin = Frame([0, 0, 1 - .3 + 1.5 / 2], [1, 0, 0], [0, 1, 0])
model.add_joint('hat_joint',
                Joint.FIXED,
                head_link,
                hat_link,
                origin=hat_joint_origin)

artist = Artist(model, layer='COMPAS::Example Robot')
artist.clear_layer()
artist.draw_visual()
Пример #12
0
     Point(1, 2, 2),
     Point(2, 2, 2),
     Point(3, 2, 0)],
    [Point(0, 3, 0),
     Point(1, 3, 0),
     Point(2, 3, 0),
     Point(3, 3, 0)],
]

surface = NurbsSurface.from_points(points=points)

# ==============================================================================
# Frames
# ==============================================================================

U, V = meshgrid(surface.u_space(), surface.v_space(), 'ij')
frames = [surface.frame_at(u, v) for u, v in zip(flatten(U), flatten(V))]

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(surface).draw()

for frame in frames:
    Artist(frame).draw()

Artist.redraw()
Пример #13
0
from compas.geometry import Point
from compas.geometry import NurbsCurve
from compas.artists import Artist
from compas.colors import Color

points = [Point(0, 0, 0), Point(3, 0, 2), Point(6, 0, -3), Point(8, 0, 0)]
curve = NurbsCurve.from_interpolation(points)

projection_point = Point(2, -1, 0)

closest_point, t = curve.closest_point(projection_point, return_parameter=True)

print(curve.point_at(t) == closest_point)

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

Artist(curve, color=Color.from_hex('#0092D2')).draw()

Artist(projection_point).draw()
Artist(closest_point).draw()

Artist.redraw()
Пример #14
0
    [Point(0, 3, 0), Point(1, 3, 0), Point(2, 3, 0), Point(3, 3, 0), Point(4, 3, 0)],
]

surface = NurbsSurface.from_points(points=points)

# ==============================================================================
# Isocurves
# ==============================================================================

u_curves = []
for u in surface.u_space():
    u_curves.append(surface.u_isocurve(u))

v_curves = []
for v in surface.v_space():
    v_curves.append(surface.v_isocurve(v))

# ==============================================================================
# Visualisation
# ==============================================================================

Artist.clear()

for curve in u_curves:
    Artist(Polyline(curve.locus())).draw()

for curve in v_curves:
    Artist(Polyline(curve.locus())).draw()

Artist.redraw()