Hyperbola
- class compas.geometry.Hyperbola[source]
Bases:
Conic
A hyperbola is defined by a coordinate frame and a major and minor axis.
It is implemented using the equation
\[\frac{x^2}{a^2} - \frac{y^2}{b^2} = 1\]and with parametric form
\[\begin{split}x(t) &= a \times \sec(t) \\ y(t) &= b \times \tan(t)\end{split}\]This means that the center of the hyperbola is at the center of the coordinate frame, the vertices of the left and right branches are at (0, -a) and (0, +a) respectively, the linear eccentricity is math::sqrt{a^2 + b^2}, and the eccentricity math::fraq{sqrt{a^2 + b^2}}{a}.
- Parameters:
- majorfloat
The major of the hyperbola.
- minorfloat
The minor of the hyperbola.
- frame
compas.geometry.Frame
, optional The local coordinate system of the hyperbola. The default value is
None
, in which case the hyperbola is constructed in the XY plane of the world coordinate system.- namestr, optional
The name of the hyperbola.
- Attributes:
- frame
compas.geometry.Frame
The coordinate frame of the hyperbola.
- transformation
Transformation
, read-only The transformation from the local coordinate system of the hyperbola (
frame
) to the world coordinate system.- majorfloat
The major radius of the hyperbola.
- minorfloat
The minor radius of the hyperbola.
- plane
compas.geometry.Plane
, read-only The plane of the hyperbola.
- semifocalfloat, read-only
The distance between the center and the focus points.
- focalfloat, read-only
The distance between the two focus points.
- eccentricityfloat, read-only
This is the ratio between the semifocal length to the length of the semi-major axis. The eccentricity of a hyperbola is a number higher than 1.
- vertex1
compas.geometry.Point
, read-only The first vertex of the hyperbola is on the positive x axis.
- vertex2
compas.geometry.Point
, read-only The second vertex of the hyperbola is on the negative x axis.
- focus1
compas.geometry.Point
, read-only The first focus of the hyperbola is on the positive x axis.
- focus2
compas.geometry.Point
, read-only The second focus of the hyperbola is on the negative x axis.
- asymptote1
compas.geometry.Line
, read-only The first asymptote of the hyperbola.
- asymptote2
compas.geometry.Line
, read-only The second asymptote of the hyperbola.
- is_closedbool, read-only
False.
- is_periodicbool, read-only
False.
- frame
Examples
Construct a hyperbola in the world XY plane.
>>> from compas.geometry import Frame, Hyperbola >>> hyperbola = Hyperbola(major=3, minor=2, frame=Frame.worldXY()) >>> hyperbola = Hyperbola(major=3, minor=2)
Construct a hyperbola such that the Z axis of its frame aligns with a given line.
>>> from compas.geometry import Line, Plane, Frame, Hyperbola >>> line = Line([0, 0, 0], [1, 1, 1]) >>> plane = Plane(line.end, line.direction) >>> hyperbola = Hyperbola(major=3, minor=2, frame=Frame.from_plane(plane))
Visualise the line, hyperbola, and frame of the hyperbola with the COMPAS viewer.
>>> from compas_viewer import Viewer >>> viewer = Viewer() >>> viewer.scene.add(line) >>> viewer.scene.add(hyperbola) >>> viewer.scene.add(hyperbola.frame) >>> viewer.show()
Methods
Normal at a specific normalized parameter.
Point at the parameter.
Tangent vector at the parameter.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the curve.
Compute the closest point on the curve to a given point.
Compute the axis-aligned bounding box of the geometry.
Compute the oriented bounding box of the geometry.
Make an independent copy of the data object.
Compute the curvature vector of the curve at a parameter.
Compute the curve parameters that divide the curve into a specific number of equal length segments.
Compute the curve parameters that divide the curve into segments of specified length.
Compute the local frame of the curve at a parameter.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Construct a parametric curve from a native curve geometry.
Load a curve from an OBJ file.
Load a curve from a STP file.
Compute the length of the curve.
Reverse the parametrisation of the curve.
Reverse a copy of the curve.
Rotate the geometry.
Returns a rotated copy of this geometry.
Scale the geometry.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Write the curve geometry to an OBJ file.
Convert the curve to a list of points.
Convert the curve to a polygon.
Convert the curve to a polyline.
Write the curve geometry to a STP file.
Transform the local coordinate system of the curve.
Returns a transformed copy of this geometry.
Translate the geometry.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.