polytex.geometry
Submodules
polytex.geometry.basic
- class polytex.geometry.basic.Curve(points)[source]
Bases:
objectA partial inheritance of polytex.geometry.Point class.
- Parameters
- pointslist, tuple or array_like
A list of Point objects.
- Attributes
ambient_dimensionReturn the dimension of the curve.
boundsReturn the bounds of the curve.
curvatureReturn the curvature of the curve.
lengthReturn the length of the curve.
tangentReturn the tangent vector of the curve at each point.
Methods
plot()Plot the curve.
save([save_path])Save the curve to a vtk file.
Convert the curve to a polygon.
- save(save_path=None)[source]
Save the curve to a vtk file.
- Parameters
- save_pathstr
The path to save the vtk file.
- Returns
- None
- property ambient_dimension
Return the dimension of the curve.
- Returns
- ambient_dimensionint
- property bounds
Return the bounds of the curve.
- Returns
- boundstuple
- property curvature
Return the curvature of the curve.
TODO: curvature of a curve
- Returns
- curvaturefloat
- property length
Return the length of the curve.
- Returns
- lengthfloat
- property tangent
Return the tangent vector of the curve at each point.
- Returns
- tangentVector object
- class polytex.geometry.basic.Ellipse2D(n: int, a: float, b: float, center=[0, 0])[source]
Bases:
object- Parameters
- nint
The number of points to generate.
- afloat
The length of the major axis.
- bfloat
The length of the minor axis.
- centerlist, tuple or array_like
The center of the ellipse.
Methods
Generate points on an ellipse.
- class polytex.geometry.basic.Line(p1, p2=None, **kwargs)[source]
Bases:
Line- Parameters
- p1Point object
The first point of the line.
- p2Point object
The second point of the line.
- Attributes
ambient_dimensionA property method that returns the dimension of LinearEntity object.
argsReturns a tuple of arguments of ‘self’.
assumptions0Return object type assumptions.
boundaryThe boundary or frontier of a set.
boundsReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
canonical_variablesReturn a dictionary mapping any variable defined in
self.bound_symbolsto Symbols that do not clash with any free symbols in the expression.closureProperty method which returns the closure of a set.
directionThe direction vector of the LinearEntity.
- expr_free_symbols
free_symbolsReturn from the atoms of self those which are free symbols.
funcThe top-level function in an expression.
infThe infimum of
self.interiorProperty method which returns the interior of a set.
- is_Complement
- is_EmptySet
- is_Intersection
- is_UniversalSet
- is_algebraic
- is_antihermitian
is_closedA property method to check whether a set is closed.
- is_commutative
is_comparableReturn True if self can be computed to a real number (or already is a real number) with precision, else False.
- is_complex
- is_composite
- is_empty
- is_even
- is_extended_negative
- is_extended_nonnegative
- is_extended_nonpositive
- is_extended_nonzero
- is_extended_positive
- is_extended_real
- is_finite
- is_finite_set
- is_hermitian
- is_imaginary
- is_infinite
- is_integer
- is_irrational
- is_negative
- is_noninteger
- is_nonnegative
- is_nonpositive
- is_nonzero
- is_odd
is_openProperty method to check whether a set is open.
- is_polar
- is_positive
- is_prime
- is_rational
- is_real
- is_transcendental
- is_zero
kindThe kind of a Set
lengthThe length of the line.
measureThe (Lebesgue) measure of
self.p1The first defining point of a linear entity.
p2The second defining point of a linear entity.
pointsThe two points used to define this linear entity.
supThe supremum of
self.
Methods
angle_between(l2)Return the non-reflex angle formed by rays emanating from the origin with directions the same as the direction vectors of the linear entities.
arbitrary_point([parameter])A parameterized point on the Line.
are_concurrent(*lines)Is a sequence of linear entities concurrent?
as_content_primitive([radical, clear])A stub to allow Basic args (like Tuple) to be skipped when computing the content and primitive components of an expression.
as_dummy()Return the expression with any objects having structurally bound symbols replaced with unique, canonical symbols within the object in which they appear and having only the default assumption for commutativity being True.
atoms(*types)Returns the atoms that form the current object.
bisectors(other)Returns the perpendicular lines which pass through the intersections of self and other that are in the same plane.
class_key()Nice order of classes.
compare(other)Return -1, 0, 1 if the object is less than, equal, or greater than other in a canonical sense.
complement(universe)The complement of 'self' w.r.t the given universe.
contains(other)Return True if other is on this Line, or False otherwise.
count(query)Count the number of matching subexpressions.
count_ops([visual])Wrapper for count_ops that returns the operation count.
distance(other)Finds the shortest distance between a line and a point.
doit(**hints)Evaluate objects that are not evaluated by default like limits, integrals, sums and products.
dummy_eq(other[, symbol])Compare two expressions and handle dummy symbols.
encloses(o)Return True if o is inside (not on or outside) the boundaries of self.
equals(other)Returns True if self and other are the same mathematical entities
evalf([n, subs, maxn, chop, strict, quad, ...])Evaluate the given formula to an accuracy of n digits.
find(query[, group])Find all subexpressions matching a query.
fromiter(args, **assumptions)Create a new object from an iterable.
has(*patterns)Test whether any subexpression matches any of the patterns.
has_free(*patterns)Return True if self has object(s)
xas a free expression else False.has_xfree(s)Return True if self has any of the patterns in s as a free argument, else False.
intersect(other)Returns the intersection of 'self' and 'other'.
intersection(other)The intersection with another geometrical entity.
is_disjoint(other)Returns True if
selfandotherare disjoint.is_parallel(l2)Are two linear entities parallel?
is_perpendicular(l2)Are two linear entities perpendicular?
is_proper_subset(other)Returns True if
selfis a proper subset ofother.is_proper_superset(other)Returns True if
selfis a proper superset ofother.is_same(b[, approx])Return True if a and b are structurally the same, else False.
is_similar(other)Return True if self and other are contained in the same line.
is_subset(other)Returns True if
selfis a subset ofother.is_superset(other)Returns True if
selfis a superset ofother.isdisjoint(other)Alias for
is_disjoint()issubset(other)Alias for
is_subset()issuperset(other)Alias for
is_superset()match(pattern[, old])Pattern matching.
matches(expr[, repl_dict, old])Helper method for match() that looks for a match between Wild symbols in self and expressions in expr.
n([n, subs, maxn, chop, strict, quad, verbose])Evaluate the given formula to an accuracy of n digits.
parallel_line(p)Create a new Line parallel to this linear entity which passes through the point p.
parameter_value(other, t)Return the parameter corresponding to the given point.
perpendicular_line(p)Create a new Line perpendicular to this linear entity which passes through the point p.
perpendicular_segment(p)Create a perpendicular line segment from p to this line.
plot_interval([parameter])The plot interval for the default geometric plot of line.
powerset()Find the Power set of
self.projection(other)Project a point, line, ray, or segment onto this linear entity.
random_point([seed])A random point on a LinearEntity.
rcall(*args)Apply on the argument recursively through the expression tree.
refine([assumption])See the refine function in sympy.assumptions
reflect(line)Reflects an object across a line.
replace(query, value[, map, simultaneous, exact])Replace matching subexpressions of
selfwithvalue.rewrite(*args[, deep])Rewrite self using a defined rule.
rotate(angle[, pt])Rotate
angleradians counterclockwise about Pointpt.scale([x, y, pt])Scale the object by multiplying the x,y-coordinates by x and y.
simplify(**kwargs)See the simplify function in sympy.simplify
smallest_angle_between(l2)Return the smallest angle formed at the intersection of the lines containing the linear entities.
sort_key([order])Return a sort key.
subs(*args, **kwargs)Substitutes old for new in an expression after sympifying args.
symmetric_difference(other)Returns symmetric difference of
selfandother.translate([x, y])Shift the object by adding to the x,y-coordinates the values x and y.
union(other)Returns the union of
selfandother.xreplace(rule)Replace occurrences of objects within the expression.
copy
could_extract_minus_sign
is_hypergeometric
- default_assumptions = {}
- class polytex.geometry.basic.ParamCurve(limits, function=[], dataset=None, krig_config=('lin', 'cub'), smooth=0.0, verbose=False)[source]
Bases:
object- Parameters
- limits3-tuple
Function parameter and lower and upper bounds.
- functionlist
The function list for each coordinate component. The default value is [].
- datasetarray_like
The dataset of the curve. The default value is None. The first column is the parameter and the other columns are the value of coordinate components.
One of the function or dataset must be given. Please note that both are given, the dataset will be ignored.
- krig_configtuple
The kriging interpolation configuration. The default value is (“lin”, “cub”). The tuple should be in the form of (drift_name, covariance_name).
- smoothfloat
The smoothing factor. The default value is 0.0.
- verbosebool
If True, print the information of the kriging process. The default value is False.
- Returns
- curveParamCurve object
Methods
eval(t_value)Evaluate the curve at a given parameter value.
bounds
- class polytex.geometry.basic.ParamCurve3D(functions, limits, **kwargs)[source]
Bases:
Curve- Parameters
- functionlist of functions
Function argument should be (x(t), y(t), z(t)) for a 3D curve.
- limits3-tuple
Function parameter and lower and upper bounds. The parameter should be the same for all three functions. For example, (t, 0, 1) is valid but ((t, 0, 1), (s, 0, 1), (u, 0, 1)) is not.
- Returns
- curveParamCurve3D object
- Attributes
ambient_dimensionThe dimension of the curve.
argsReturns a tuple of arguments of ‘self’.
assumptions0Return object type assumptions.
boundaryThe boundary or frontier of a set.
boundsReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
canonical_variablesReturn a dictionary mapping any variable defined in
self.bound_symbolsto Symbols that do not clash with any free symbols in the expression.closureProperty method which returns the closure of a set.
- expr_free_symbols
free_symbolsReturn a set of symbols other than the bound symbols used to parametrically define the Curve.
funcThe top-level function in an expression.
functionsThe functions specifying the curve.
infThe infimum of
self.interiorProperty method which returns the interior of a set.
- is_Complement
- is_EmptySet
- is_Intersection
- is_UniversalSet
- is_algebraic
- is_antihermitian
is_closedA property method to check whether a set is closed.
- is_commutative
is_comparableReturn True if self can be computed to a real number (or already is a real number) with precision, else False.
- is_complex
- is_composite
- is_empty
- is_even
- is_extended_negative
- is_extended_nonnegative
- is_extended_nonpositive
- is_extended_nonzero
- is_extended_positive
- is_extended_real
- is_finite
- is_finite_set
- is_hermitian
- is_imaginary
- is_infinite
- is_integer
- is_irrational
- is_negative
- is_noninteger
- is_nonnegative
- is_nonpositive
- is_nonzero
- is_odd
is_openProperty method to check whether a set is open.
- is_polar
- is_positive
- is_prime
- is_rational
- is_real
- is_transcendental
- is_zero
kindThe kind of a Set
lengthThe length of the curve.
limitsThe limits for the curve.
measureThe (Lebesgue) measure of
self.parameterThe curve function variable.
supThe supremum of
self.
Methods
__call__(f)Call self as a function.
arbitrary_point([parameter])A parameterized point on the curve.
as_content_primitive([radical, clear])A stub to allow Basic args (like Tuple) to be skipped when computing the content and primitive components of an expression.
as_dummy()Return the expression with any objects having structurally bound symbols replaced with unique, canonical symbols within the object in which they appear and having only the default assumption for commutativity being True.
atoms(*types)Returns the atoms that form the current object.
class_key()Nice order of classes.
compare(other)Return -1, 0, 1 if the object is less than, equal, or greater than other in a canonical sense.
complement(universe)The complement of 'self' w.r.t the given universe.
contains(other)Returns a SymPy value indicating whether
otheris contained inself:trueif it is,falseif it is not, else an unevaluatedContainsexpression (or, as in the case of ConditionSet and a union of FiniteSet/Intervals, an expression indicating the conditions for containment).count(query)Count the number of matching subexpressions.
count_ops([visual])Wrapper for count_ops that returns the operation count.
doit(**hints)Evaluate objects that are not evaluated by default like limits, integrals, sums and products.
dummy_eq(other[, symbol])Compare two expressions and handle dummy symbols.
encloses(o)Return True if o is inside (not on or outside) the boundaries of self.
eval(t_value)Evaluate the curve at a given parameter value.
evalf([n, subs, maxn, chop, strict, quad, ...])Evaluate the given formula to an accuracy of n digits.
find(query[, group])Find all subexpressions matching a query.
fromiter(args, **assumptions)Create a new object from an iterable.
has(*patterns)Test whether any subexpression matches any of the patterns.
has_free(*patterns)Return True if self has object(s)
xas a free expression else False.has_xfree(s)Return True if self has any of the patterns in s as a free argument, else False.
intersect(other)Returns the intersection of 'self' and 'other'.
intersection(o)Returns a list of all of the intersections of self with o.
is_disjoint(other)Returns True if
selfandotherare disjoint.is_proper_subset(other)Returns True if
selfis a proper subset ofother.is_proper_superset(other)Returns True if
selfis a proper superset ofother.is_same(b[, approx])Return True if a and b are structurally the same, else False.
is_similar(other)Is this geometrical entity similar to another geometrical entity?
is_subset(other)Returns True if
selfis a subset ofother.is_superset(other)Returns True if
selfis a superset ofother.isdisjoint(other)Alias for
is_disjoint()issubset(other)Alias for
is_subset()issuperset(other)Alias for
is_superset()match(pattern[, old])Pattern matching.
matches(expr[, repl_dict, old])Helper method for match() that looks for a match between Wild symbols in self and expressions in expr.
n([n, subs, maxn, chop, strict, quad, verbose])Evaluate the given formula to an accuracy of n digits.
parameter_value(other, t)Return the parameter corresponding to the given point.
plot_interval([parameter])The plot interval for the default geometric plot of the curve.
powerset()Find the Power set of
self.rcall(*args)Apply on the argument recursively through the expression tree.
refine([assumption])See the refine function in sympy.assumptions
reflect(line)Reflects an object across a line.
replace(query, value[, map, simultaneous, exact])Replace matching subexpressions of
selfwithvalue.rewrite(*args[, deep])Rewrite self using a defined rule.
rotate(angle[, axis])This function is used to rotate a curve along given point
ptat given angle(in radian).scale([x, y, z])Override GeometryEntity.scale since Curve is not made up of Points.
simplify(**kwargs)See the simplify function in sympy.simplify
sort_key([order])Return a sort key.
subs(*args, **kwargs)Substitutes old for new in an expression after sympifying args.
symmetric_difference(other)Returns symmetric difference of
selfandother.translate([x, y, z])Translate the Curve by (x, y, z).
union(other)Returns the union of
selfandother.xreplace(rule)Replace occurrences of objects within the expression.
copy
could_extract_minus_sign
equals
is_hypergeometric
- eval(t_value)[source]
Evaluate the curve at a given parameter value. The parameter value should be within the limits. Otherwise, an error will be raised.
- Parameters
- t_valuefloat or array_like
The parameter value for evaluation.
- Returns
- curveCurve object
The evaluated curve.
- rotate(angle, axis='z')[source]
This function is used to rotate a curve along given point
ptat given angle(in radian).- Parameters
- angle
the angle at which the curve will be rotated(in radian) in counterclockwise direction. default value of angle is 0.
- ptPoint
the point along which the curve will be rotated. If no point given, the curve will be rotated around origin.
- Returns
- Curve
returns a curve rotated at given angle along given point.
Examples
>>> from sympy import Curve, pi >>> from sympy.abc import x >>> Curve((x, x), (x, 0, 1)).rotate(pi/2) Curve((-x, x), (x, 0, 1))
- scale(x=1, y=1, z=1)[source]
Override GeometryEntity.scale since Curve is not made up of Points.
- Returns
- Curve
returns scaled curve.
Examples
>>> from sympy import Curve >>> from sympy.abc import x >>> Curve((x, x), (x, 0, 1)).scale(2) Curve((2*x, x), (x, 0, 1))
- translate(x=0, y=0, z=0)[source]
Translate the Curve by (x, y, z).
- Parameters
- xfloat
The translation in the x direction.
- yfloat
The translation in the y direction.
- zfloat
The translation in the z direction.
- Returns
- Curve
returns a translated curve.
Examples
>>> from polytex.geometry import ParamCurve3D >>> from sympy.abc import x >>> ParamCurve3D((x, x), (x, 0, 1)).translate(1, 2) ParamCurve3D((x + 1, x + 2), (x, 0, 1))
- property bounds
Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
- default_assumptions = {}
- property length
The length of the curve.
- class polytex.geometry.basic.ParamSurface(functions, limits, **kwargs)[source]
Bases:
GeometryEntity- Parameters
- functionslist of functions
Function argument should be (x(s, t), y(s, t), z(s, t)) for a 3D surface.
- limits2-tuple
Function parameter and lower and upper bounds of the two parameters. For example, ((s, 0, 1), (t, 0, 1)) is valid. The parameter should be the same for all three functions.
- Attributes
argsReturns a tuple of arguments of ‘self’.
assumptions0Return object type assumptions.
boundsReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
canonical_variablesReturn a dictionary mapping any variable defined in
self.bound_symbolsto Symbols that do not clash with any free symbols in the expression.- expr_free_symbols
free_symbolsReturn from the atoms of self those which are free symbols.
funcThe top-level function in an expression.
functionsThe functions specifying the surface.
- is_algebraic
- is_antihermitian
- is_commutative
is_comparableReturn True if self can be computed to a real number (or already is a real number) with precision, else False.
- is_complex
- is_composite
- is_even
- is_extended_negative
- is_extended_nonnegative
- is_extended_nonpositive
- is_extended_nonzero
- is_extended_positive
- is_extended_real
- is_finite
- is_hermitian
- is_imaginary
- is_infinite
- is_integer
- is_irrational
- is_negative
- is_noninteger
- is_nonnegative
- is_nonpositive
- is_nonzero
- is_odd
- is_polar
- is_positive
- is_prime
- is_rational
- is_real
- is_transcendental
- is_zero
limitsThe limits of the two parameters specifying the surface.
Methods
as_content_primitive([radical, clear])A stub to allow Basic args (like Tuple) to be skipped when computing the content and primitive components of an expression.
as_dummy()Return the expression with any objects having structurally bound symbols replaced with unique, canonical symbols within the object in which they appear and having only the default assumption for commutativity being True.
atoms(*types)Returns the atoms that form the current object.
class_key()Nice order of classes.
compare(other)Return -1, 0, 1 if the object is less than, equal, or greater than other in a canonical sense.
count(query)Count the number of matching subexpressions.
count_ops([visual])Wrapper for count_ops that returns the operation count.
doit(**hints)Evaluate objects that are not evaluated by default like limits, integrals, sums and products.
dummy_eq(other[, symbol])Compare two expressions and handle dummy symbols.
encloses(o)Return True if o is inside (not on or outside) the boundaries of self.
eval(s_value, t_value)Evaluate the surface at the given parameter values.
evalf([n, subs, maxn, chop, strict, quad, ...])Evaluate the given formula to an accuracy of n digits.
find(query[, group])Find all subexpressions matching a query.
fromiter(args, **assumptions)Create a new object from an iterable.
has(*patterns)Test whether any subexpression matches any of the patterns.
has_free(*patterns)Return True if self has object(s)
xas a free expression else False.has_xfree(s)Return True if self has any of the patterns in s as a free argument, else False.
intersection(o)Returns a list of all of the intersections of self with o.
is_same(b[, approx])Return True if a and b are structurally the same, else False.
match(pattern[, old])Pattern matching.
matches(expr[, repl_dict, old])Helper method for match() that looks for a match between Wild symbols in self and expressions in expr.
n([n, subs, maxn, chop, strict, quad, verbose])Evaluate the given formula to an accuracy of n digits.
rcall(*args)Apply on the argument recursively through the expression tree.
refine([assumption])See the refine function in sympy.assumptions
replace(query, value[, map, simultaneous, exact])Replace matching subexpressions of
selfwithvalue.rewrite(*args[, deep])Rewrite self using a defined rule.
rotate(angle[, axis])Rotate
angleradians counterclockwise about Pointpt.scale([x, y, z])Scale the object by multiplying the x,y-coordinates by x and y.
simplify(**kwargs)See the simplify function in sympy.simplify
sort_key([order])Return a sort key.
subs(*args, **kwargs)Substitutes old for new in an expression after sympifying args.
translate([x, y, z])Shift the object by adding to the x,y-coordinates the values x and y.
xreplace(rule)Replace occurrences of objects within the expression.
copy
could_extract_minus_sign
is_hypergeometric
- eval(s_value, t_value)[source]
Evaluate the surface at the given parameter values.
- Parameters
- s_valuefloat or array_like
The parameter value for evaluation.
- t_valuefloat or array_like
The parameter value for evaluation.
- Returns
- Surface
The surface evaluated at the given parameter values. the shape of the returned surface is (len(s) * len(t), 3). The first column is s values, the second column is t values, and the following columns are the coordinates of the surface at the given parameter values (x, y, z).
- rotate(angle, axis='z')[source]
Rotate
angleradians counterclockwise about Pointpt.The default pt is the origin, Point(0, 0)
Examples
>>> from sympy import Point, RegularPolygon, Polygon, pi >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t # vertex on x axis Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.rotate(pi/2) # vertex on y axis now Triangle(Point2D(0, 1), Point2D(-sqrt(3)/2, -1/2), Point2D(sqrt(3)/2, -1/2))
- scale(x=1, y=1, z=1)[source]
Scale the object by multiplying the x,y-coordinates by x and y.
If pt is given, the scaling is done relative to that point; the object is shifted by -pt, scaled, and shifted by pt.
Examples
>>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.scale(2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)/2), Point2D(-1, -sqrt(3)/2)) >>> t.scale(2, 2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)), Point2D(-1, -sqrt(3)))
- translate(x=0, y=0, z=0)[source]
Shift the object by adding to the x,y-coordinates the values x and y.
Examples
>>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.translate(2) Triangle(Point2D(3, 0), Point2D(3/2, sqrt(3)/2), Point2D(3/2, -sqrt(3)/2)) >>> t.translate(2, 2) Triangle(Point2D(3, 2), Point2D(3/2, sqrt(3)/2 + 2), Point2D(3/2, 2 - sqrt(3)/2))
- default_assumptions = {}
- property functions
The functions specifying the surface.
- Returns
- functions
list of parameterized coordinate functions.
Examples
>>> from sympy.abc import t >>> from polytex.geometry import ParamCurve3D >>> surface = ParamSurface((t, t, t), ((t, 0, 1), (t, 0, 1))) >>> surface.functions (t, t, t)
- property limits
The limits of the two parameters specifying the surface.
- Returns
- list limits of the parameters.
Examples
>>> from sympy.abc import t >>> from polytex.geometry import ParamCurve3D >>> surface = ParamSurface((t, t, t), ((t, 0, 1), (t, 0, 1))) >>> surface.limits ((t, 0, 1), (t, 0, 1))
- class polytex.geometry.basic.Plane(p1, a=None, b=None, **kwargs)[source]
Bases:
objectCreate a plane from 3 points or a point and a normal vector.
- Parameters
- p1Point object
A point on the plane.
- aPoint object, optional
A point on the plane. The default is None.
- bPoint object, optional
A point on the plane. The default is None.
- **kwargsdict, optional
normal_vector can be passed as a keyword argument when leaving a and b as None. If both a and b are not None, normal_vector will be ignored.
- Returns
- planePlane object
Methods
distance(point)Return the signed distance between a point and the plane.
function()Return the equation of the plane as a function of x, y and z.
intersection(obj, max_dist)Return the intersection of the plane with a curve or a polygon.
show()Plot the plane.
- distance(point)[source]
Return the signed distance between a point and the plane.
- Parameters
- pointPoint object
The point to calculate the distance. shape = (n, 3), where n is the number of points.
- Returns
- distancefloat
The distance between the point and the plane.
Examples
>>> from polytex.geometry import Point, Plane >>> p1 = Point([5, 0, 0]) >>> normal = Point([1, 0, 0]) >>> plane = Plane(p1, normal_vector=normal) >>> plane.show() >>> plane.distance([[0, 0, 0], [1, 0, 0], [2, 0, 0]]) array([-5., -4., -3.])
- function()[source]
Return the equation of the plane as a function of x, y and z.
- Parameters
- normalarray-like
normal vector of the plane.
- pointarray-like
point on the plane.
- Returns
- A lambda function of x, y and z.
function of plane.
Notes
normal = (a, b, c) point = (x0, y0, z0) Equation of a plane: a(x-x0) + b(y-y0) + c(z-z0) = 0
Examples
Create a plane from a point and a normal vector >>> from polytex.geometry import Point, Plane >>> p1 = Point([1, 1, 1]) >>> normal = Point([1, 4, 7]) >>> plane2 = Plane(p1, normal_vector=normal) >>> f = plane2.function() >>> f <function polytex.geometry.basic.Plane.function.<locals>.<lambda>(x, y, z)> >>> f(1, 1, 1) 0
- intersection(obj, max_dist)[source]
Return the intersection of the plane with a curve or a polygon.
- Parameters
- objCurve or Polygon object
The object to intersect with the plane.
- max_distfloat
The maximum distance of checked points from the plane.
- Returns
- intersectionlist or array
The intersection point of the plane with the obj in the shape of (1, 3). If the intersection is not found, none is returned.
- class polytex.geometry.basic.Point(orig_3d=(0, 0, 0))[source]
Bases:
ndarrayDefault constructor. If no arguments are given, the point is initialized to (0, 0, 0).
- Parameters
- clsclass
The class of the object.
- orig_3dtuple, list, or array_like
Defaults to 3d origin (0, 0, 0).
- Returns
- objPoint
The origin point of 3d space.
Examples
>>> p1 = Point() >>> p1 Point([0, 0, 0])
- Attributes
TThe transposed array.
baseBase object if memory is from some other object.
boundsReturns ——- bounds : array_like The bounding box of the point.
ctypesAn object to simplify the interaction of the array with the ctypes module.
dataPython buffer object pointing to the start of the array’s data.
dtypeData-type of the array’s elements.
flagsInformation about the memory layout of the array.
flatA 1-D iterator over the array.
imagThe imaginary part of the array.
itemsizeLength of one array element in bytes.
nbytesTotal bytes consumed by the elements of the array.
ndimNumber of array dimensions.
realThe real part of the array.
shapeTuple of array dimensions.
sizeNumber of elements in the array.
stridesTuple of bytes to step in each dimension when traversing an array.
- x
- xyz
- y
zReturn —— z : float 3rd dimension element.
Methods
all([axis, out, keepdims, where])Returns True if all elements evaluate to True.
any([axis, out, keepdims, where])Returns True if any of the elements of a evaluate to True.
argmax([axis, out, keepdims])Return indices of the maximum values along the given axis.
argmin([axis, out, keepdims])Return indices of the minimum values along the given axis.
argpartition(kth[, axis, kind, order])Returns the indices that would partition this array.
argsort([axis, kind, order])Returns the indices that would sort this array.
astype(dtype[, order, casting, subok, copy])Copy of the array, cast to a specified type.
byteswap([inplace])Swap the bytes of the array elements
choose(choices[, out, mode])Use an index array to construct a new array from a set of choices.
clip([min, max, out])Return an array whose values are limited to
[min, max].compress(condition[, axis, out])Return selected slices of this array along given axis.
conj()Complex-conjugate all elements.
conjugate()Return the complex conjugate, element-wise.
copy([order])Return a copy of the array.
cumprod([axis, dtype, out])Return the cumulative product of the elements along the given axis.
cumsum([axis, dtype, out])Return the cumulative sum of the elements along the given axis.
diagonal([offset, axis1, axis2])Return specified diagonals.
direction_ratio(other)Gives the direction ratio between 2 points.
dist(other)Both points must have the same dimensions :return: Euclidean distance
dump(file)Dump a pickle of the array to the specified file.
dumps()Returns the pickle of the array as a string.
fill(value)Fill the array with a scalar value.
flatten([order])Return a copy of the array collapsed into one dimension.
getfield(dtype[, offset])Returns a field of the given array as a certain type.
item(*args)Copy an element of an array to a standard Python scalar and return it.
itemset(*args)Insert scalar into an array (scalar is cast to array's dtype, if possible)
max([axis, out, keepdims, initial, where])Return the maximum along a given axis.
mean([axis, dtype, out, keepdims, where])Returns the average of the array elements along given axis.
min([axis, out, keepdims, initial, where])Return the minimum along a given axis.
newbyteorder([new_order])Return the array with the same data viewed with a different byte order.
nonzero()Return the indices of the elements that are non-zero.
partition(kth[, axis, kind, order])Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array.
prod([axis, dtype, out, keepdims, initial, ...])Return the product of the array elements over the given axis
ptp([axis, out, keepdims])Peak to peak (maximum - minimum) value along a given axis.
put(indices, values[, mode])Set
a.flat[n] = values[n]for all n in indices.ravel([order])Return a flattened array.
repeat(repeats[, axis])Repeat elements of an array.
reshape(shape[, order])Returns an array containing the same data with a new shape.
resize(new_shape[, refcheck])Change shape and size of array in-place.
round([decimals, out])Return a with each element rounded to the given number of decimals.
save_as_vtk(filename[, color])Save the point as a vtk file.
searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order.
setfield(val, dtype[, offset])Put a value into a specified place in a field defined by a data-type.
setflags([write, align, uic])Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.
sort([axis, kind, order])Sort an array in-place.
squeeze([axis])Remove axes of length one from a.
std([axis, dtype, out, ddof, keepdims, where])Returns the standard deviation of the array elements along given axis.
sum([axis, dtype, out, keepdims, initial, where])Return the sum of the array elements over the given axis.
swapaxes(axis1, axis2)Return a view of the array with axis1 and axis2 interchanged.
take(indices[, axis, out, mode])Return an array formed from the elements of a at the given indices.
tobytes([order])Construct Python bytes containing the raw data bytes in the array.
tofile(fid[, sep, format])Write array to a file as text or binary (default).
tolist()Return the array as an
a.ndim-levels deep nested list of Python scalars.tostring([order])A compatibility alias for tobytes, with exactly the same behavior.
trace([offset, axis1, axis2, dtype, out])Return the sum along diagonals of the array.
transpose(*axes)Returns a view of the array with axes transposed.
var([axis, dtype, out, ddof, keepdims, where])Returns the variance of the array elements, along given axis.
view([dtype][, type])New view of array with the same data.
dot
set_x
set_y
set_z
- direction_ratio(other)[source]
Gives the direction ratio between 2 points.
- Parameters
- otherPoint object
The other point to which the direction ratio is calculated.
- Returns
- direction_ratiolist
The direction ratio between the 2 points.
Examples
>>> from polytex.geometry import Point >>> p1 = Point(1, 2, 3) >>> p1.direction_ratio(Point(2, 3, 5)) [1, 1, 2]
- property bounds
- Returns
- boundsarray_like
The bounding box of the point. The first row is the minimum values and the second row is the maximum values for each dimension.
- property size
Number of elements in the array.
Equal to
np.prod(a.shape), i.e., the product of the array’s dimensions.Notes
a.size returns a standard arbitrary precision Python integer. This may not be the case with other methods of obtaining the same value (like the suggested
np.prod(a.shape), which returns an instance ofnp.int_), and may be relevant if the value is used further in calculations that may overflow a fixed size integer type.Examples
>>> x = np.zeros((3, 5, 2), dtype=np.complex128) >>> x.size 30 >>> np.prod(x.shape) 30
- property x
- property xyz
- property y
- property z
- class polytex.geometry.basic.Polygon(points)[source]
Bases:
CurveA partial inheritance of polytex.geometry.Point class.
- Parameters
- pointslist, tuple or array_like
A list of Point objects.
- Attributes
ambient_dimensionReturn the dimension of the curve.
areaReturn the area of the polygon.
boundsReturn the bounds of the curve.
centroidReturn the centroid of the polygon.
curvatureReturn the curvature of the curve.
lengthReturn the length of the curve.
perimeterReturn the perimeter of the polygon.
tangentReturn the tangent vector of the curve at each point.
Methods
plot()Plot the curve.
save([save_path])Save the curve to a vtk file.
to_curve()Convert the polygon to a curve.
to_polygon()Convert the curve to a polygon.
- property area
Return the area of the polygon.
- Returns
- areafloat
- property centroid
Return the centroid of the polygon.
- Returns
- centroidPoint object
- property perimeter
Return the perimeter of the polygon.
- Returns
- perimeterfloat
- class polytex.geometry.basic.Tube(theta_res, h_res, vertices=None, **kwargs)[source]
Bases:
GeometryEntityCreate a tubular surface.
- Parameters
- theta_resint
The number of points on each cross-section.
- h_resint
The number of cross-sections.
- verticesarray_like
The points on the cross-sections. The shape of the array should be (h_res * theta_res, 3). The points should be ordered in the following way: [p1, p2, …, p_theta_res, p1, p2, …, p_theta_res, …, p1, p2, …, p_theta_res] where p1, p2, …, p_theta_res are the points on each cross-section from the top to the bottom. The default value is None. If the value is None, the points will be generated automatically by assigning the height, major and minor radius to the tube.
- Returns
- tubeTube object
Examples
>>> from polytex.geometry import Tube >>> tube = Tube(4, 10, major=2, minor=1, h=5) >>> mesh = tube.mesh(plot=True) >>> tube.save_as_mesh('tube.vtk')
- Attributes
argsReturns a tuple of arguments of ‘self’.
assumptions0Return object type assumptions.
boundsReturn a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
canonical_variablesReturn a dictionary mapping any variable defined in
self.bound_symbolsto Symbols that do not clash with any free symbols in the expression.- expr_free_symbols
free_symbolsReturn from the atoms of self those which are free symbols.
funcThe top-level function in an expression.
- h_res
- is_algebraic
- is_antihermitian
- is_commutative
is_comparableReturn True if self can be computed to a real number (or already is a real number) with precision, else False.
- is_complex
- is_composite
- is_even
- is_extended_negative
- is_extended_nonnegative
- is_extended_nonpositive
- is_extended_nonzero
- is_extended_positive
- is_extended_real
- is_finite
- is_hermitian
- is_imaginary
- is_infinite
- is_integer
- is_irrational
- is_negative
- is_noninteger
- is_nonnegative
- is_nonpositive
- is_nonzero
- is_odd
- is_polar
- is_positive
- is_prime
- is_rational
- is_real
- is_transcendental
- is_zero
- points
- theta_res
Methods
as_content_primitive([radical, clear])A stub to allow Basic args (like Tuple) to be skipped when computing the content and primitive components of an expression.
as_dummy()Return the expression with any objects having structurally bound symbols replaced with unique, canonical symbols within the object in which they appear and having only the default assumption for commutativity being True.
atoms(*types)Returns the atoms that form the current object.
class_key()Nice order of classes.
compare(other)Return -1, 0, 1 if the object is less than, equal, or greater than other in a canonical sense.
count(query)Count the number of matching subexpressions.
count_ops([visual])Wrapper for count_ops that returns the operation count.
doit(**hints)Evaluate objects that are not evaluated by default like limits, integrals, sums and products.
dummy_eq(other[, symbol])Compare two expressions and handle dummy symbols.
encloses(o)Return True if o is inside (not on or outside) the boundaries of self.
evalf([n, subs, maxn, chop, strict, quad, ...])Evaluate the given formula to an accuracy of n digits.
find(query[, group])Find all subexpressions matching a query.
fromiter(args, **assumptions)Create a new object from an iterable.
has(*patterns)Test whether any subexpression matches any of the patterns.
has_free(*patterns)Return True if self has object(s)
xas a free expression else False.has_xfree(s)Return True if self has any of the patterns in s as a free argument, else False.
intersection(o)Returns a list of all of the intersections of self with o.
is_same(b[, approx])Return True if a and b are structurally the same, else False.
match(pattern[, old])Pattern matching.
matches(expr[, repl_dict, old])Helper method for match() that looks for a match between Wild symbols in self and expressions in expr.
mesh([plot, show_edges])TODO : raise TypeError("Given points must be a sequence or an array.")
n([n, subs, maxn, chop, strict, quad, verbose])Evaluate the given formula to an accuracy of n digits.
rcall(*args)Apply on the argument recursively through the expression tree.
refine([assumption])See the refine function in sympy.assumptions
replace(query, value[, map, simultaneous, exact])Replace matching subexpressions of
selfwithvalue.rewrite(*args[, deep])Rewrite self using a defined rule.
rotate(angle[, pt])Rotate
angleradians counterclockwise about Pointpt.save_as_mesh(save_path[, end_closed])Save the tubular mesh to a file.
scale([x, y, pt])Scale the object by multiplying the x,y-coordinates by x and y.
simplify(**kwargs)See the simplify function in sympy.simplify
sort_key([order])Return a sort key.
subs(*args, **kwargs)Substitutes old for new in an expression after sympifying args.
translate([x, y])Shift the object by adding to the x,y-coordinates the values x and y.
xreplace(rule)Replace occurrences of objects within the expression.
copy
could_extract_minus_sign
is_hypergeometric
- mesh(plot=False, show_edges=True)[source]
TODO : raise TypeError(“Given points must be a sequence or an array.”)
Notes
theta_res should be 1 less then else where. To be fixed in the future.
- save_as_mesh(save_path, end_closed=True)[source]
Save the tubular mesh to a file. The file format is determined by the extension of the filename. The possible file formats are: [“.ply”, “.stl”, “.vtk”, “.vtu”].
TODO : There seems to be a bug in correction option of the to_meshio_data() method of the tubular mesh.
- Parameters
- save_pathstr
The path and the name of the file to be saved with the extension.
- end_closedbool
If True, the ends of the tube will be closed. The default value is True.
- Returns
- meshpyvista.UnstructuredGrid
The tubular mesh.
Examples
>>> from polytex.geometry import Tube >>> tube = Tube(5,10,major=2, minor=1,h=5) >>> tube.save_as_mesh('tube.vtu')
- property bounds
Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
- default_assumptions = {}
- property h_res: int
- property points
- property theta_res: int
- class polytex.geometry.basic.Vector(orig_3d=(0, 0, 0))[source]
Bases:
PointDefault constructor. If no arguments are given, the point is initialized to (0, 0, 0).
- Parameters
- clsclass
The class of the object.
- orig_3dtuple, list, or array_like
Defaults to 3d origin (0, 0, 0).
- Returns
- objPoint
The origin point of 3d space.
Examples
>>> p1 = Point() >>> p1 Point([0, 0, 0])
- Attributes
TThe transposed array.
- add
baseBase object if memory is from some other object.
boundsReturns ——- bounds : array_like The bounding box of the point.
ctypesAn object to simplify the interaction of the array with the ctypes module.
dataPython buffer object pointing to the start of the array’s data.
dtypeData-type of the array’s elements.
flagsInformation about the memory layout of the array.
flatA 1-D iterator over the array.
imagThe imaginary part of the array.
itemsizeLength of one array element in bytes.
nbytesTotal bytes consumed by the elements of the array.
ndimNumber of array dimensions.
normReturn —— norm : float The norm of the vector.
realThe real part of the array.
shapeTuple of array dimensions.
sizeNumber of elements in the array.
stridesTuple of bytes to step in each dimension when traversing an array.
- sub
- x
- xyz
- y
zReturn —— z : float 3rd dimension element.
Methods
all([axis, out, keepdims, where])Returns True if all elements evaluate to True.
angle_between(other[, radian])Return the angle between 2 vectors.
any([axis, out, keepdims, where])Returns True if any of the elements of a evaluate to True.
argmax([axis, out, keepdims])Return indices of the maximum values along the given axis.
argmin([axis, out, keepdims])Return indices of the minimum values along the given axis.
argpartition(kth[, axis, kind, order])Returns the indices that would partition this array.
argsort([axis, kind, order])Returns the indices that would sort this array.
astype(dtype[, order, casting, subok, copy])Copy of the array, cast to a specified type.
byteswap([inplace])Swap the bytes of the array elements
choose(choices[, out, mode])Use an index array to construct a new array from a set of choices.
clip([min, max, out])Return an array whose values are limited to
[min, max].compress(condition[, axis, out])Return selected slices of this array along given axis.
conj()Complex-conjugate all elements.
conjugate()Return the complex conjugate, element-wise.
copy([order])Return a copy of the array.
cumprod([axis, dtype, out])Return the cumulative product of the elements along the given axis.
cumsum([axis, dtype, out])Return the cumulative sum of the elements along the given axis.
diagonal([offset, axis1, axis2])Return specified diagonals.
direction_ratio(other)Gives the direction ratio between 2 points.
dist(other)Both points must have the same dimensions :return: Euclidean distance
dump(file)Dump a pickle of the array to the specified file.
dumps()Returns the pickle of the array as a string.
fill(value)Fill the array with a scalar value.
flatten([order])Return a copy of the array collapsed into one dimension.
getfield(dtype[, offset])Returns a field of the given array as a certain type.
item(*args)Copy an element of an array to a standard Python scalar and return it.
itemset(*args)Insert scalar into an array (scalar is cast to array's dtype, if possible)
max([axis, out, keepdims, initial, where])Return the maximum along a given axis.
mean([axis, dtype, out, keepdims, where])Returns the average of the array elements along given axis.
min([axis, out, keepdims, initial, where])Return the minimum along a given axis.
newbyteorder([new_order])Return the array with the same data viewed with a different byte order.
nonzero()Return the indices of the elements that are non-zero.
partition(kth[, axis, kind, order])Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array.
prod([axis, dtype, out, keepdims, initial, ...])Return the product of the array elements over the given axis
ptp([axis, out, keepdims])Peak to peak (maximum - minimum) value along a given axis.
put(indices, values[, mode])Set
a.flat[n] = values[n]for all n in indices.ravel([order])Return a flattened array.
repeat(repeats[, axis])Repeat elements of an array.
reshape(shape[, order])Returns an array containing the same data with a new shape.
resize(new_shape[, refcheck])Change shape and size of array in-place.
round([decimals, out])Return a with each element rounded to the given number of decimals.
save_as_vtk(filename[, color])Save the point as a vtk file.
searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order.
setfield(val, dtype[, offset])Put a value into a specified place in a field defined by a data-type.
setflags([write, align, uic])Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.
sort([axis, kind, order])Sort an array in-place.
squeeze([axis])Remove axes of length one from a.
std([axis, dtype, out, ddof, keepdims, where])Returns the standard deviation of the array elements along given axis.
sum([axis, dtype, out, keepdims, initial, where])Return the sum of the array elements over the given axis.
swapaxes(axis1, axis2)Return a view of the array with axis1 and axis2 interchanged.
take(indices[, axis, out, mode])Return an array formed from the elements of a at the given indices.
tobytes([order])Construct Python bytes containing the raw data bytes in the array.
tofile(fid[, sep, format])Write array to a file as text or binary (default).
tolist()Return the array as an
a.ndim-levels deep nested list of Python scalars.tostring([order])A compatibility alias for tobytes, with exactly the same behavior.
trace([offset, axis1, axis2, dtype, out])Return the sum along diagonals of the array.
transpose(*axes)Returns a view of the array with axes transposed.
var([axis, dtype, out, ddof, keepdims, where])Returns the variance of the array elements, along given axis.
view([dtype][, type])New view of array with the same data.
cross
dot
set_x
set_y
set_z
- angle_between(other, radian=False)[source]
Return the angle between 2 vectors.
\[\theta = \arccos \frac{v_1 \cdot v_2}{\|v_1\| \|v_2\|}\]- Parameters
- otherVector object
The other vector to which the angle is calculated.
- radianbool, optional
If True, return the angle in radians. The default is False.
- Returns
- anglefloat
The angle between the 2 vectors. If radian is True, the angle is in radians. Otherwise, the angle is in degrees.
- property add
- property norm
- property sub
- polytex.geometry.basic.find_intersect(f, curve, niterations=5, mSegments=5)[source]
Find the intersection of a curve with a plane
- Parameters
- flambda function
function of plane.
- curvearray-like
points on the curve in shape of (n, 3).
- niterations: int
number of iterations.
- mSegments: int
number of segments for each iteration.
- Returns
- intersection: array-like
intersection points with shape (n, 3).
polytex.geometry.geometry
- polytex.geometry.geometry.angularSort(localCo, centroid, sort=True)[source]
Sort the vertices of a 2D polygon in angular order. It can be a convex or concave polygon.
- Parameters
- localCoNumpy array
with 2 columns. The x, y coordinate components of the vertices of the polygon (For the cross-section of fiber tows, it is the coordinate in the local coordinate system with its center at the centroid of the polygon).
- centroidNumpy array
with 2 columns. The x, y coordinate components of the centroid of the polygon.
- sortBoolean
If True, the vertices are sorted in angular order. If False, the vertices are not sorted and returned following the original order with angular position for each input vertices.
- Returns
- coorSortNumpy array
with 3 columns. The x, y coordinate components of the vertices of the polygon sorted in angular order. The third column is the z coordinate in 3D case.
- angleNumpy array
with 1 column. The angular position of the vertices of the polygon in degrees. The two returns are sorted in the same order if sort is True. Otherwise, the two returns are not sorted, and are following the original order of the input vertices.
- polytex.geometry.geometry.area_signed(points: ndarray) float[source]
Return the signed area of a simple polygon given the 2D coordinates of its veritces.
The signed area is computed using the shoelace algorithm. A positive area is returned for a polygon whose vertices are given by a counter-clockwise sequence of points.
- Parameters
- pointsarray_like
Input 2D points of the polygon in the shape (n, 2). If the polygon is 3D, An error is raised. Note that the points have to be ordered in a clockwise or counter-clockwise manner. Otherwise, the area will be non-sense.
- Returns
- area_signedfloat
The signed area of the polygon.
- Raises
- ValueError
If the points are not 2D.
Notes
If the number of points is less than 3, a warning is raised and the area is
returned as 0. - This function is modified from open source Python library scikit-spatial: skspatial.measurement — scikit-spatial documentation https://scikit-spatial.readthedocs.io/en/stable/_modules/skspatial/measurement.html#area_signed)
Examples
>>> from polytex.geometry import area_signed
>>> area_signed([[0, 0], [1, 0], [0, 1]]) 0.5
>>> area_signed([[0, 0], [0, 1], [1, 0]]) -0.5
>>> area_signed([[0, 0], [0, 1], [1, 2], [2, 1], [2, 0]]) -3.0
- polytex.geometry.geometry.edgeLen(localCo, boundType='rotated')[source]
the width and height of rotated_rectangle
- Parameters
- localCoNumpy array
with 2 columns. The x, y coordinate components of the vertices of the polygon (For the cross-section of fiber tows, it is the coordinate in the local coordinate system with its center at the centroid of the polygon).
- boundType: string
rotated or parallel
- Returns
- widthfloat
The width of the minimum rotated rectangle that contains the polygon.
- heightfloat
The height of the minimum rotated rectangle that contains the polygon.
- angleRotatedfloat
The angle of rotation of the minimum rotated rectangle that contains the polygon.
- polytex.geometry.geometry.geom_cs(coordinate, message='OFF', sort=True)[source]
Geometry analysis and points sorting for a cross-section of a fiber tow.
- Parameters
- coordinateNumpy array
with 3 colums. The x, y, z coordinate components of the vertices of the polygon. Note that only the first two columns are used for the 2D polygon.
- Returns
- geometry filex,y,z of points, and x,y,z of centerline
- properties: area… …
- polytex.geometry.geometry.geom_tow(surf_points, sort=True)[source]
The surface points for each cross-section. the last column (z-axis) should be along the extension direction of the cross-sections. It also serves as the label of each cross-section.
- Parameters
- surf_pointsarray_like
The surface points for each cross-section. the last column (z-axis) should be along the extension direction of the cross-sections. It also serves as the label of each cross-section.
- sortBoolean
If True, the vertices are sorted in angular order. If False, the vertices are not sorted and returned following the original order with angular position for each input vertices.
- Returns
- df_geomDataFrame
The geometrical features of each cross-section. The columns are: [Area, Perimeter, Width, Height, AngleRotated, Circularity, centroidX, centroidY, centroidZ]
- df_cooDataFrame
The coordinates of each cross-section. The columns are: [distance, normalized distance, angular position (degree), X, Y, Z)]
- polytex.geometry.geometry.normDist(localCo)[source]
The normalized distance of the vertices of a polygon
- Parameters
- localCoNumpy array
with 2 columns. The x, y coordinate components of the vertices of the polygon (For the cross-section of fiber tows, it is the coordinate in the local coordinate system with its center at the centroid of the polygon).
polytex.geometry.transform
- polytex.geometry.transform.d2r(degrees: float) float[source]
Convert degrees to radians.
- Parameters
- degreesfloat
Angle in degrees.
- Returns
- float
Angle in radians.
- polytex.geometry.transform.e123_dcm(psi: float, theta: float, phi: float) ndarray[source]
This function chaining the rotation matrices for the Euler 123 sequence. The rotation matrix is defined as:
\[R = R_3(psi) R_2(theta) R_1(phi)\]where \(R_1\) is the rotation matrix about the x-axis, \(R_2\) is the rotation matrix about the y-axis, and \(R_3\) is the rotation matrix about the z-axis.
- Parameters
- psifloat
The rotation angle about the z-axis in radians.
- thetafloat
The rotation angle about the y-axis in radians.
- phifloat
The rotation angle about the x-axis in radians.
- Returns
- dcmnumpy.ndarray
The direction cosine matrix for the Euler 123 sequence.
Examples
>>> import polytex.geometry.transform as tf
- polytex.geometry.transform.euler_z_noraml(normal, *args) list[source]
This function returns the euler angles (phi, theta, psi) for rotating the global coordinate system to align its z-axis with a normal vector from the origin to a point (namely, no translation is considered).
- Parameters
- normallist or array
The normal vector from the origin to a point.
- Returns
- euler_angleslist
The euler angles (psi, theta, phi), where psi is the rotation angle about the z-axis, theta is the rotation angle about the y-axis, and phi is the rotation angle about the x-axis in radians. Note that the rotation should be performed in the order of e123 by pre-multiplying the rotation matrices.
Notes
No translation is considered. The origin of the global coordinate system is assumed to be the origin of the local coordinate system. The user should translate the local coordinate system to the origin before calling this function and then re-translate the local coordinate system to the desired location.
Examples
>>> import polytex.geometry.transform as tf >>> import numpy as np >>> normal = [0.43583834, -0.00777955, -0.89999134] >>> euler_angles = tf.euler_z_noraml(normal) >>> print(np.allclose(euler_angles, [0, 0.4509695318910846, 3.132948841252596])) True >>> print("As we are rotating the global coordinate system to align its z-axis with the normal vector,") >>> print("the normal vector should be [0, 0, 1] after the rotation.") >>> tf.e123_dcm(*euler_angles) @ normal >>> print(np.allclose(tf.e123_dcm(*euler_angles) @ normal, [0, 0, 1])) True
- polytex.geometry.transform.euler_zx_coordinate(z_new, x_new) list[source]
This function returns the euler angles (phi, theta, psi) for rotating the global coordinate system to align its z-axis with the z_new vector and its x-axis with the x_new vector.
- Parameters
- z_newlist or array
The coordinate of the new z-axis in the original coordinate system.
- x_newlist or array
The coordinate of the new x-axis in the original coordinate system.
- Returns
- euler_angleslist
The euler angles (psi, theta, phi), where psi is the rotation angle about the z-axis, theta is the rotation angle about the y-axis, and phi is the rotation angle about the x-axis in radians. Note that the rotation should be done in e123 sequence by pre-multiplying the rotation matrices.
Notes
No translation is considered. The origin of the global coordinate system is assumed to be the origin of the local coordinate system. The user should translate the local coordinate system to the origin before calling this function and then re-translate the local coordinate system to the desired location.
Examples
>>> import polytex.geometry.transform as tf
- polytex.geometry.transform.rx(phi: float) ndarray[source]
Single axis frame rotation about the X-axis.
- Parameters
- phifloat
The angle between z-axis (or y-axis) of the initial and final frames in radian. The rotation is positive if the frame rotates in the counter-clockwise direction when viewed from the positive end of x-axis.
- Returns
- numpy.ndarray
Rotation matrix.
- polytex.geometry.transform.ry(theta: float) ndarray[source]
Single axis frame rotation about the Y-axis.
- Parameters
- thetafloat
The angle between z-axis (or x-axis) of the initial and final frames in radian. The rotation is positive if the frame rotates in the counter-clockwise direction when viewed from the positive end of y-axis.
- polytex.geometry.transform.rz(psi: float) ndarray[source]
Single axis frame rotation about the Z-axis.
- Parameters
- psifloat
The angle between x-axis (or y-axis) of the initial and final frames in radian. The rotation is positive if the frame rotates in the counter-clockwise direction when viewed from the positive end of z axis.
- Returns
- numpy.ndarray
Rotation matrix.