Ejemplo n.º 1
0
from compas.geometry import Point, Polyline, Vector
from compas.geometry import offset_polyline
from compas.utilities import linspace

from compas_plotters import GeometryPlotter

controlpoints = [
    Point(0, 0, 0),
    Point(4, 2.5, 0),
    Point(6, -2.5, 0),
    Point(10, 0, 0)
]
controlpoly = Polyline(controlpoints)

curve = Bezier(controlpoints)
poly = Polyline(curve.locus())
poly1 = Polyline(offset_polyline(poly, +0.15))
poly2 = Polyline(offset_polyline(poly, -0.15))

points = [curve.point(t) for t in linspace(0, 1, 20)]
tangents = [curve.tangent(t) for t in linspace(0, 1, 20)]
normals = [Vector(0, 0, 1).cross(t) for t in tangents]

# ==============================================================================
# Visualization
# ==============================================================================

plotter = GeometryPlotter(figsize=(16, 9))

plotter.add(controlpoly,
            linestyle='dotted',
Ejemplo n.º 2
0
from compas.geometry import Point
from compas.geometry import Polyline, Bezier
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)]
bezier = Bezier(points)
points = bezier.locus(10)

curve = NurbsCurve.from_interpolation(points)

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

Artist.clear()

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

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

Artist.redraw()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
# 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))

Artist.redraw()
Ejemplo n.º 5
0
                                       multiplicities=[3, 1, 3],
                                       degree=2)

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

view = App()

view.add(Polyline(bezier.points),
         show_points=True,
         pointsize=20,
         pointcolor=(1, 0, 0),
         linewidth=1,
         linecolor=(0.3, 0.3, 0.3))
view.add(Polyline(bezier.locus()), linewidth=5, linecolor=(0, 0, 0))

view.add(Polyline(curve1.points),
         show_points=True,
         pointsize=20,
         pointcolor=(1, 0, 0),
         linewidth=1,
         linecolor=(0.3, 0.3, 0.3))
view.add(Polyline(curve1.locus()), linewidth=5, linecolor=(0, 0, 0))
view.add(Polyline(curve2.locus()), linewidth=3, linecolor=(0, 0, 1))
view.add(Polyline(curve3.locus()), linewidth=3, linecolor=(0.2, 0.2, 1))
view.add(Polyline(curve4.locus()), linewidth=3, linecolor=(0.4, 0.4, 1))
view.add(Polyline(curve5.locus()), linewidth=3, linecolor=(0.6, 0.6, 1))
view.add(Polyline(curve6.locus()), linewidth=3, linecolor=(0.8, 0.8, 1))

view.run()