curves

curves

Curve classes for the cxregions package.

This module contains all curve-related classes including the base JuliaCurve class and specific curve types like Line, Circle, Segment, Ray, and Arc.

Attributes

Name Description
unitcircle Unit circle centered at the origin.

Classes

Name Description
Arc A circular arc in the complex plane.
Circle A circle in the complex plane.
ClosedCurve A closed parametric curve in the complex plane.
Curve A general parametric curve in the complex plane.
JuliaCurve Base class for wrapping Julia curve objects from ComplexRegions.jl.
Line An infinite straight line in the complex plane.
Ray A semi-infinite ray in the complex plane.
Segment A line segment in the complex plane.

Arc

curves.Arc(a, b=None, c=None)

A circular arc in the complex plane.

An arc is a portion of a circle between two points.

Parameters

Name Type Description Default
a complex, Circle, or juliacall.AnyValue Start point, circle, or Julia Arc object to wrap required
b complex End point (if a is start point) None
c complex Center point (if constructing from start, end, center) None

Attributes

Name Type Description
circle Circle or Segment The underlying circle (or degenerate segment)
start float Starting parameter on the circle
delta float Parameter range of the arc

Examples

>>> # Quarter circle arc from 1 to i around origin
>>> arc = Arc(1, 1j, 0)

Methods

Name Description
inv Compute the inversion of the arc with respect to the origin.
inv
curves.Arc.inv()

Compute the inversion of the arc with respect to the origin.

Returns
Name Type Description
Arc, Ray, or Segment The type depends on the geometry after inversion

Circle

curves.Circle(a, b=None, c=None, ccw=True)

A circle in the complex plane.

Circles can be constructed in several ways: - From center and radius - From three points on the circle - From a Julia Circle object

Parameters

Name Type Description Default
a complex or juliacall.AnyValue Center point, first point on circle, or Julia Circle object required
b float or complex Radius (if a is center) or second point on circle None
c complex Third point on circle (if constructing from three points) None
ccw bool Whether the circle has counterclockwise orientation, default True True

Attributes

Name Type Description
center complex Center of the circle
radius float Radius of the circle
ccw bool Whether the circle has counterclockwise orientation

Examples

>>> # Unit circle at origin
>>> circle1 = Circle(0, 1)
>>> # Circle from center and radius with clockwise orientation
>>> circle2 = Circle(1+1j, 2, ccw=False)
>>> # Circle through three points
>>> circle3 = Circle(1, 1j, -1)

Methods

Name Description
inv Compute the inversion of the circle with respect to the origin.
isfinite Check if the circle is finite.
ispositive Check if the circle has positive (counterclockwise) orientation.
inv
curves.Circle.inv()

Compute the inversion of the circle with respect to the origin.

Returns
Name Type Description
Circle or Line Circle if the original circle doesn’t pass through the origin, Line if it does
isfinite
curves.Circle.isfinite()

Check if the circle is finite.

Returns
Name Type Description
bool Always returns True for circles
ispositive
curves.Circle.ispositive()

Check if the circle has positive (counterclockwise) orientation.

Returns
Name Type Description
bool True if counterclockwise, False if clockwise

ClosedCurve

curves.ClosedCurve(point, tangent=None, domain=(0.0, 1.0))

A closed parametric curve in the complex plane.

This class represents a closed curve that forms a Jordan curve, enabling computation of winding numbers and interior/exterior tests.

Parameters

Name Type Description Default
point callable or juliacall.AnyValue Either a function that maps parameter values to complex points, or a Julia closed curve object to wrap required
tangent callable Function that maps parameter values to tangent vectors None
domain tuple of float Parameter domain as (start, end), default is (0.0, 1.0) (0.0, 1.0)

Examples

>>> # Create a closed curve (unit circle)
>>> point = lambda t: np.exp(2j * np.pi * t)
>>> tangent = lambda t: 2j * np.pi * np.exp(2j * np.pi * t)
>>> curve = ClosedCurve(point, tangent)

Methods

Name Description
hasinside Check if point z is in the interior of the closed curve.
winding Compute the winding number of the curve around point z.
hasinside
curves.ClosedCurve.hasinside(z)

Check if point z is in the interior of the closed curve.

Parameters
Name Type Description Default
z complex Point to test required
Returns
Name Type Description
bool True if z is in the interior, False otherwise
winding
curves.ClosedCurve.winding(z)

Compute the winding number of the curve around point z.

Parameters
Name Type Description Default
z complex Point around which to compute winding number required
Returns
Name Type Description
int Winding number (positive for counterclockwise orientation)

Curve

curves.Curve(point, tangent=None, domain=(0.0, 1.0))

A general parametric curve in the complex plane.

This class represents a curve defined by a point function and optional tangent function over a parameter domain.

Parameters

Name Type Description Default
point callable or juliacall.AnyValue Either a function that maps parameter values to complex points, or a Julia curve object to wrap required
tangent callable Function that maps parameter values to tangent vectors None
domain tuple of float Parameter domain as (start, end), default is (0.0, 1.0) (0.0, 1.0)

Examples

>>> # Create a curve from a function
>>> curve = Curve(lambda t: t + 1j*t**2, lambda t: 1 + 2j*t)

Methods

Name Description
inv Compute the inversion of the curve with respect to the origin.
inv
curves.Curve.inv()

Compute the inversion of the curve with respect to the origin.

Returns
Name Type Description
Curve Inverted curve

JuliaCurve

curves.JuliaCurve(julia_obj)

Base class for wrapping Julia curve objects from ComplexRegions.jl.

This class provides a Python interface to Julia curve objects, handling the conversion between Python and Julia types and providing access to geometric operations on curves.

Parameters

Name Type Description Default
julia_obj juliacall.AnyValue A Julia curve object from ComplexRegions.jl required

Attributes

Name Type Description
julia juliacall.AnyValue The underlying Julia curve object

Methods

Name Description
arclength Compute the arc length of the curve.
arg Find the parameter value corresponding to point z on the curve.
closest Find the closest point on the curve to z.
conj Return the complex conjugate of the curve.
dist Compute the distance from point z to the curve.
get Get a field from the underlying Julia object.
intersect Find intersection points with another curve.
inv Compute the inversion of the curve with respect to the origin.
isapprox Check if this curve is approximately equal to another.
isfinite Check if the curve has finite length.
isleft Check if point z is to the left of the curve.
ispositive Check if the curve has positive orientation.
isreal Check if the curve lies on the real axis.
isright Check if point z is to the right of the curve.
normal Compute the normal at parameter t.
point Evaluate the curve at parameter value t.
reflect Reflect point z across the curve.
reverse Return the curve with reversed orientation.
tangent Compute the tangent at parameter t.
unittangent Compute the unit tangent at parameter t.
arclength
curves.JuliaCurve.arclength()

Compute the arc length of the curve.

Returns
Name Type Description
float Total arc length of the curve
arg
curves.JuliaCurve.arg(z)

Find the parameter value corresponding to point z on the curve.

Parameters
Name Type Description Default
z complex Point to locate on the curve required
Returns
Name Type Description
float or None Parameter value if z is on the curve, None otherwise
closest
curves.JuliaCurve.closest(z)

Find the closest point on the curve to z.

Parameters
Name Type Description Default
z complex Reference point required
Returns
Name Type Description
complex Closest point on the curve to z
conj
curves.JuliaCurve.conj()

Return the complex conjugate of the curve.

Returns
Name Type Description
JuliaCurve Complex conjugate of this curve
dist
curves.JuliaCurve.dist(z)

Compute the distance from point z to the curve.

Parameters
Name Type Description Default
z complex Reference point required
Returns
Name Type Description
float Distance from z to the closest point on the curve
get
curves.JuliaCurve.get(field)

Get a field from the underlying Julia object.

Parameters
Name Type Description Default
field str Name of the field to retrieve required
Returns
Name Type Description
Any The value of the requested field
intersect
curves.JuliaCurve.intersect(other)

Find intersection points with another curve.

Parameters
Name Type Description Default
other JuliaCurve Another curve to intersect with required
Returns
Name Type Description
numpy.ndarray or JuliaCurve Array of intersection points, or a curve if the intersection is a continuous curve segment
inv
curves.JuliaCurve.inv()

Compute the inversion of the curve with respect to the origin.

Returns
Name Type Description
juliacall.AnyValue Julia object representing the inverted curve
Notes

This method returns a raw Julia object. Subclasses should override this method to return properly wrapped Python objects.

isapprox
curves.JuliaCurve.isapprox(other)

Check if this curve is approximately equal to another.

Parameters
Name Type Description Default
other JuliaCurve Another curve to compare with required
Returns
Name Type Description
bool True if curves are approximately equal, False otherwise
isfinite
curves.JuliaCurve.isfinite()

Check if the curve has finite length.

Returns
Name Type Description
bool True if the curve is finite, False otherwise
isleft
curves.JuliaCurve.isleft(z)

Check if point z is to the left of the curve.

Parameters
Name Type Description Default
z complex Point to test required
Returns
Name Type Description
bool True if z is to the left of the curve, False otherwise
ispositive
curves.JuliaCurve.ispositive()

Check if the curve has positive orientation.

Returns
Name Type Description
bool True if positively oriented, False otherwise
isreal
curves.JuliaCurve.isreal()

Check if the curve lies on the real axis.

Returns
Name Type Description
bool True if the curve is real, False otherwise
isright
curves.JuliaCurve.isright(z)

Check if point z is to the right of the curve.

Parameters
Name Type Description Default
z complex Point to test required
Returns
Name Type Description
bool True if z is to the right of the curve, False otherwise
normal
curves.JuliaCurve.normal(t)

Compute the normal at parameter t.

Parameters
Name Type Description Default
t float Parameter value required
Returns
Name Type Description
complex Normal at parameter t
point
curves.JuliaCurve.point(t)

Evaluate the curve at parameter value t.

Parameters
Name Type Description Default
t float Parameter value, typically in [0, 1] required
Returns
Name Type Description
complex Point on the curve at parameter t
reflect
curves.JuliaCurve.reflect(z)

Reflect point z across the curve.

Parameters
Name Type Description Default
z complex Point to reflect required
Returns
Name Type Description
complex Reflected point
reverse
curves.JuliaCurve.reverse()

Return the curve with reversed orientation.

Returns
Name Type Description
JuliaCurve Curve with reversed orientation
tangent
curves.JuliaCurve.tangent(t=0.0)

Compute the tangent at parameter t.

Parameters
Name Type Description Default
t float Parameter value, default is 0 0.0
Returns
Name Type Description
complex Tangent at parameter t
unittangent
curves.JuliaCurve.unittangent(t=0.0)

Compute the unit tangent at parameter t.

Parameters
Name Type Description Default
t float Parameter value, default is 0 0.0
Returns
Name Type Description
complex Unit tangent at parameter t

Line

curves.Line(a, b=None, direction=None)

An infinite straight line in the complex plane.

A line can be constructed from two points, or from a point and a direction. Lines have infinite arc length and are always considered to have positive orientation.

Parameters

Name Type Description Default
a complex or juliacall.AnyValue Either a point on the line, or a Julia Line object to wrap required
b complex Second point on the line (if constructing from two points) None
direction complex Direction vector of the line (if constructing from point and direction) None

Attributes

Name Type Description
base complex A base point on the line
direction complex Direction vector of the line

Examples

>>> # Line through two points
>>> line1 = Line(0, 1+1j)
>>> # Line through origin with given direction
>>> line2 = Line(0, direction=1+1j)

Methods

Name Description
angle Get the angle of the line’s direction vector.
arclength Return infinite arc length for lines.
inv Compute the inversion of the line with respect to the origin.
isfinite Check if the line is finite.
ispositive Check if the line has positive orientation.
slope Get the slope of the line.
angle
curves.Line.angle()

Get the angle of the line’s direction vector.

Returns
Name Type Description
float Angle in radians
arclength
curves.Line.arclength()

Return infinite arc length for lines.

Returns
Name Type Description
float Always returns numpy.inf
inv
curves.Line.inv()

Compute the inversion of the line with respect to the origin.

Returns
Name Type Description
Circle or Line Circle if the line doesn’t pass through the origin, Line otherwise
isfinite
curves.Line.isfinite()

Check if the line is finite.

Returns
Name Type Description
bool Always returns False for lines
ispositive
curves.Line.ispositive()

Check if the line has positive orientation.

Returns
Name Type Description
bool Always returns True for lines
slope
curves.Line.slope()

Get the slope of the line.

Returns
Name Type Description
float Slope of the line (dy/dx)

Ray

curves.Ray(base, angle=None)

A semi-infinite ray in the complex plane.

A ray starts at a base point and extends infinitely in a given direction.

Parameters

Name Type Description Default
base complex or juliacall.AnyValue Starting point of the ray or Julia Ray object to wrap required
angle float Angle of the ray direction in radians None

Attributes

Name Type Description
base complex Starting point of the ray
angle float Angle of the ray direction

Examples

>>> # Ray from origin at 45 degrees
>>> ray = Ray(0, np.pi/4)

Segment

curves.Segment(a, b=None)

A line segment in the complex plane.

A segment is a finite portion of a line connecting two endpoints.

Parameters

Name Type Description Default
a complex or juliacall.AnyValue First endpoint or Julia Segment object to wrap required
b complex Second endpoint (if a is first endpoint) None

Attributes

Name Type Description
first complex First endpoint of the segment
last complex Last endpoint of the segment

Examples

>>> # Segment from origin to (1,1)
>>> seg = Segment(0, 1+1j)

Methods

Name Description
inv Compute the inversion of the segment with respect to the origin.
inv
curves.Segment.inv()

Compute the inversion of the segment with respect to the origin.

Returns
Name Type Description
Arc, Ray, or Segment The type depends on the geometry after inversion

Functions

Name Description
wrap_jl_curve Wrap a Julia curve object in the appropriate Python class.

wrap_jl_curve

curves.wrap_jl_curve(jul)

Wrap a Julia curve object in the appropriate Python class.

Parameters

Name Type Description Default
jul juliacall.AnyValue A Julia curve object from ComplexRegions.jl required

Returns

Name Type Description
Curve The appropriate Python curve wrapper (Circle, Arc, Line, Segment, Ray, etc.)

Raises

Name Type Description
ValueError If the argument is not a Julia object or not a recognized curve type