Shape modifiers

The following classes modify an existing shape. They are Shapes themselves, executing a certain algorithm on an original_shape parameter. They can be used to transform (i.e., round, grow, shrink) geometrical elements.

ipkiss.geometry.shapes.modifiers.ShapeRound(…) Returns a shape with rounded corners based on a given shape
ipkiss.geometry.shapes.modifiers.ShapeStub(…) Stubs the corners of a given shape
ipkiss.geometry.shapes.modifiers.ShapeSample(…) Creates a shape sampling points on another shape along specified distances between the sampling point.
ipkiss.geometry.shapes.modifiers.ShapeSamplePeriodic(…) Creates a shape sampling points on another shape along specified periodic distances from the start point of the shape.
ipkiss.geometry.shapes.modifiers.ShapeShorten(…) Shortens a shape on both ends by given trim lengths.
ipkiss.geometry.shapes.modifiers.ShapeSerif(…) Puts a bump on the corners of a given shape.
ipkiss.geometry.shapes.modifiers.ShapeGrow(…) Generates a shape which uniformly grows.
ipkiss.geometry.shapes.modifiers.ShapeVariableOffset(…) Generates a shape with a variable offset from its original shape.
ipkiss.geometry.shapes.modifiers.ShapeExtendEnds(…) Stubs the corners of a given shape.
ipkiss.geometry.shapes.modifiers.ShapeFit(…) Fits a shape in a given box.
ipkiss.geometry.shapes.spline.ShapeRoundAdiabaticSpline(…) Returns a shape with adiabatic spline corners

ShapeRound

class ipkiss.geometry.shapes.modifiers.ShapeRound(original_shape, **kwargs)

Returns a shape with rounded corners based on a given shape

Parameters:

radius: float and Real, number and number >= 0, required

original_shape: Shape, required

angle_step: float, optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

radii: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
rounded_shape = i3.ShapeRound(original_shape=shape,
                              radius=5.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(rounded_shape.x_coords(), rounded_shape.y_coords(), 'r-', label='rounded shape')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-1.png

ShapeSample

class ipkiss.geometry.shapes.modifiers.ShapeSample(original_shape, **kwargs)

Creates a shape sampling points on another shape along specified distances between the sampling point.

Parameters:

sampling_distances: list<number > 0>, required

original_shape: Shape, required

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
sampled_shape = i3.ShapeSample(original_shape=shape,
                               sampling_distances=[1.0, 3.0, 3.5, 4.0, 7.0, 7.8, 10.0, 12.0, 15.0, 17.0, 25.0])
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(sampled_shape.x_coords(), sampled_shape.y_coords(), 'ro', label='sampled shape', markersize=7)
plt.legend()
plt.show()
../../../_images/shape_modifiers-2.png

ShapeSamplePeriodic

class ipkiss.geometry.shapes.modifiers.ShapeSamplePeriodic(original_shape, **kwargs)

Creates a shape sampling points on another shape along specified periodic distances from the start point of the shape.

Parameters:

sampling_period: float and number > 0, required

original_shape: Shape, required

exclude_ends: Coord2, optional

Lengths not taken into account on both ends

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

sampling_distances: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
sampled_shape = i3.ShapeSamplePeriodic(original_shape=shape,
                                       sampling_period=0.5,
                                       exclude_ends=(1.0, 2.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(sampled_shape.x_coords(), sampled_shape.y_coords(), 'ro', label='sampled shape', markersize=7)
plt.legend()
plt.show()
../../../_images/shape_modifiers-3.png

ShapeStub

class ipkiss.geometry.shapes.modifiers.ShapeStub(original_shape, **kwargs)

Stubs the corners of a given shape

On closed shapes, all corners are stubbed Open shapes are left open: the edge corners are not stubbed

Parameters:

stub_width: float and Real, number and number >= 0, required

original_shape: Shape, required

only_sharp_angles: optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
stubbed_shape = i3.ShapeStub(original_shape=shape,
                             only_sharp_angles=False,
                             stub_width=5.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(stubbed_shape.x_coords(), stubbed_shape.y_coords(), 'r-', label='stubbed shape')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-4.png

ShapeShorten

class ipkiss.geometry.shapes.modifiers.ShapeShorten(original_shape, **kwargs)

Shortens a shape on both ends by given trim lengths.

Parameters:

original_shape: Shape, required

trim_lengths: Coord2, optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
short_shape = i3.ShapeShorten(original_shape=shape,
                              trim_lengths=(1.0, 2.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(short_shape.x_coords(), short_shape.y_coords(), 'ro--', label='shortened shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-5.png

ShapeSerif

class ipkiss.geometry.shapes.modifiers.ShapeSerif(**kwargs)

Puts a bump on the corners of a given shape.

Parameters:

stub_height: float and number > 0, required

stub_width: float and number > 0, required

tip_width: float and Real, number and number >= 0, required

original_shape: Shape, required

only_sharp_angles: optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
serif_shape = i3.ShapeSerif(original_shape=shape,
                            stub_width=3.0,
                            stub_height=2.0,
                            tip_width=2.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(serif_shape.x_coords(), serif_shape.y_coords(), 'r-', label='serif shape')
plt.xlim([0, 30.0])
plt.ylim([0, 15.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-6.png

ShapeGrow

class ipkiss.geometry.shapes.modifiers.ShapeGrow(original_shape, amount, **kwargs)

Generates a shape which uniformly grows.

Parameters:

amount: float, required

original_shape: Shape, required

offset: optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
grown_shape = i3.ShapeGrow(original_shape=shape,
                           amount=2.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(grown_shape.x_coords(), grown_shape.y_coords(), 'ro--', label='grown shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-7.png

ShapeVariableOffset

class ipkiss.geometry.shapes.modifiers.ShapeVariableOffset(original_shape, offsets, **kwargs)

Generates a shape with a variable offset from its original shape.

Parameters:

offsets: list<Real, number>, required

original_shape: Shape, required

remove_loopbacks: optional

end_face_angle: float, optional

start_face_angle: float, optional

points: optional

points of this shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
offset_shape = i3.ShapeVariableOffset(original_shape=shape,
                                      offsets=[-1.0, 2.0, 3.0, -1.0, 0.0])
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(offset_shape.x_coords(), offset_shape.y_coords(), 'ro--', label='offset shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-8.png

ShapeExtendEnds

class ipkiss.geometry.shapes.modifiers.ShapeExtendEnds(original_shape, start_extension, end_extension, **kwargs)

Stubs the corners of a given shape.

Parameters:

end_extension: float, required

start_extension: float, required

original_shape: Shape, required

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
extended_shape = i3.ShapeExtendEnds(original_shape=shape,
                                    start_extension=1.0,
                                    end_extension=3.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=6)
plt.plot(extended_shape.x_coords(), extended_shape.y_coords(), 'ro--', label='extended shape', markersize=2, linewidth=3)
plt.legend()
plt.show()
../../../_images/shape_modifiers-9.png

ShapeRoundAdiabaticSpline

class ipkiss.geometry.shapes.spline.ShapeRoundAdiabaticSpline(original_shape, **kwargs)

Returns a shape with adiabatic spline corners

Parameters:

radius: float and Real, number and number >= 0, required

original_shape: Shape, required

adiabatic_angles: tuple2, optional

angle_step: float, optional

end_face_angle: optional

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: optional

Use this to overrule the ‘dangling’ angle at the start of an open shape

adiabatic_angles_list: locked

radii: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
rounded_shape = i3.ShapeRoundAdiabaticSpline(original_shape=shape,
                                             radius=3.0,
                                             adiabatic_angles=(10.0, 10.0))
rounded_shape2 = i3.ShapeRoundAdiabaticSpline(original_shape=shape,
                                             radius=3.0,
                                             adiabatic_angles=(40.0, 40.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(rounded_shape.x_coords(), rounded_shape.y_coords(), 'r-', label='rounded shape (10$\degree$)')
plt.plot(rounded_shape2.x_coords(), rounded_shape2.y_coords(), 'g-', label='rounded shape (40$\degree$)')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-10.png