Contents

On this page


triellipt.geom

Geometry module.

line()

triellipt.geom.line(startpoint, endpoint)

Creates a line between two points.

Parameters

startpoint : complex

Start point.

endpoint : complex

End point.

Returns

Line

Line as a curve-like object.

hyperb()

triellipt.geom.hyperb(axes, ksis, etas)

Creates a hyperbolic curve.

Parameters

axes : (float, float)

Hyperbolic parameters (a, b).

ksis : (float, float)

Interval of ksi parameter (in [-1, 1]).

etas : (float, float)

Interval of eta parameter (≥0).

Returns

Hyperb

Hyperbola as a curve-like object.

elliparc()

triellipt.geom.elliparc(center, axes, phis, tilt=0)

Creates an elliptic arc.

Parameters

center : (float, float)

Ellipse center.

axes : (float, float)

Major and minor ellipse axes.

phis : (float, float)

Start and end arc angles.

tilt : float = 0

Ellipse rotation angle around the center.

Returns

EllipArc

Elliptic arc as a curve-like object.

bezier2()

triellipt.geom.bezier2(point0, point1, point2)

Creates a quadratic Bezier curve.

Parameters

point0 : complex

1st control point (startpoint).

point1 : complex

2nd control point.

point2 : complex

3rd control point (endpoint).

Returns

Bezier2

Curve-like object.

bezier3()

triellipt.geom.bezier3(point0, point1, point2, point3)

Creates a cubic Bezier curve.

Parameters

point0 : complex

1st control point (startpoint).

point1 : complex

2nd control point.

point2 : complex

3rd control point.

point3 : complex

4th control point (endpoint).

Returns

Bezier3

Curve-like object.

makeloop()

triellipt.geom.makeloop(*curves)

Creates a loop of connected curves.

Parameters

curves : *one-of-the-curves

Sequence of connected curves.

Returns

CurvesLoop

Loop of connected curves.

makerect()

triellipt.geom.makerect(corner, dims)

Creates a rectangle as a loop.

Parameters

corner : (float, float)

South-west rectangle corner.

dims : (float, float)

Width and height of the rectangle.

Returns

CurvesLoop

Loop of rectangle sides (south-east-north-west).

makeellip()

triellipt.geom.makeellip(center, axes, tilt=0)

Creates a closed ellipse as a loop.

Parameters

center : (float, float)

Ellipse center.

axes : (float, float)

Major and minor axes.

tilt : float = 0

Ellipse rotation angle.

Returns

CurvesLoop

Ellipse as a single-curve loop.

makecycle()

triellipt.geom.makecycle(path)

Creates a cyclic path.

Parameters

path : flat-complex-array

Input path.

Returns

CycPath

Path closed to a cycle.

Curve

class triellipt.geom.Curve()

Base class for parametric curves on [0, 1].

getpath()

Curve.getpath(self, *args)

Picks points on the curve.

Parameters

args : *float

Parameters in [0, 1].

Returns

flat-complex-array

Points on the curve.

linspace()

Curve.linspace(self, nparts)

Splits the curve uniformly in the parameter space.

Parameters

nparts : int

Number of intervals in the parameter space.

Returns

flat-complex-array

The resulting polygonal path.

partition()

Curve.partition(self, nparts, ratio=1)

Splits the curve into segments based on length.

Parameters

nparts : int

Number of segments in the partition.

ratio : float = 1

Ratio of segments lengths (last-to-first).

Returns

flat-complex-array

The resulting polygonal chain.

length()

Curve.length(self, *, places=4, maxitr=10)

Estimates the curve length iteratively.

Parameters

places : int = 4

Number of decimal places to resolve.

maxitr : int = 10

Maximum number of iterations.

Returns

float

Length estimate.

CurvesLoop

class triellipt.geom.CurvesLoop(curves=None)

Loop of connected curves.

Attributes

curves : tuple

Sequence of connected curves.

Properties

Name Description
startpoints Curves start points.
endpoints Curves end points.

discretize()

CurvesLoop.discretize(self, *params)

Discretizes the curves loop.

Parameters

params : *(nparts, ratio)

Partition parameters for each curve, see Curve().partition()

Returns

PathsMap

Polygonal path colored at curves.

PathMap

class triellipt.geom.PathMap(nodes=None)

Polygonal path with colored nodes.

Properties

Name Description
colors Nodes colors.
numbers Nodes numbers.
points Nodes positions (complex).
points2d Nodes positions (xy-rows).

togeo()

PathMap.togeo(self, geopath, seeds) → None

Dumps path to the geo file.

Parameters

geopath : str

Absolute path to the .geo file.

seeds : dict

Maps colours to the seed mesh sizes.

atcolors()

PathMap.atcolors(self, *colors)

Fetches a subpath with the specified colors.

Parameters

colors : *int

Colors in the subpath.

Returns

PathMap

The resulting subpath.

repaint()

PathMap.repaint(self, color, newcolor)

Changes the specified color to the new one.

rshift()

PathMap.rshift(self, color1, color2)

Shifts the contact of two colors to the right by one node.

lshift()

PathMap.lshift(self, color1, color2)

Shifts the contact of two colors to the left by one node.

CycPath

class triellipt.geom.CycPath(nodes=None)

Cyclic polygonal path.

Properties

Name Description
points Nodes positions.
numbers Nodes numbers.

angles()

CycPath.angles(self)

Provides rotation angles of edges.

Returns

flat-float-array

Rotation angles of edges at each node.

dissect()

CycPath.dissect(self, angle)

Splits the cycle based on rotation angle.

Parameters

angle : float

Threshold angle for a node to become a corner.

Returns

PathMap

Partition of a cycle.

Copyright © 2023, Igor Semenov.