Ellipse
Ellipse Geometric Object
Ellipse
Bases: ContinuousGeometryEntity
Ellipse geometrical object
Source code in otary/geometry/continuous/shape/ellipse.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
area
property
Compute the area of the ellipse
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
area value |
centroid
property
Compute the center point of the ellipse
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
2D point defining the center of the ellipse |
eccentricity
property
Eccentricity value of the ellipse
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
eccentricity value |
focal_distance
property
Distance from any focal point to the center
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
focal distance value |
h
property
h is a common ellipse value used in calculation and kind of represents the eccentricity of the ellipse but in another perspective.
Circle would have a h = 0. A really stretch out ellipse would have a h value close o 1
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
h value |
is_circle
property
Check if the ellipse is a circle
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if circle else False |
linear_eccentricity
property
Distance from any focal point to the center
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
linear eccentricity value |
perimeter
property
Compute the perimeter of the ellipse. Beware this is only an approximation due to the computation of both pi and the James Ivory's infinite serie.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
perimeter value |
semi_minor_axis
property
Computed semi minor axis (also called b usually)
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
description |
shapely_edges
property
Returns the Shapely.LinearRing as a curve representation of the Ellipse. See https://shapely.readthedocs.io/en/stable/reference/shapely.LinearRing.html
Returns:
Name | Type | Description |
---|---|---|
LinearRing |
LinearRing
|
shapely.LinearRing object |
shapely_surface
property
Returns the Shapely.Polygon as an surface representation of the Ellipse. See https://shapely.readthedocs.io/en/stable/reference/shapely.Polygon.html
Returns:
Name | Type | Description |
---|---|---|
Polygon |
Polygon
|
shapely.Polygon object |
__assert_ellipse()
Assert the parameters of the ellipse. If the parameters proposed do not make up a ellipse raise an error.
Source code in otary/geometry/continuous/shape/ellipse.py
__init__(foci1, foci2, semi_major_axis, n_points_polygonal_approx=ContinuousGeometryEntity.DEFAULT_N_POLY_APPROX)
Initialize a Ellipse geometrical object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
foci1
|
NDArray | list
|
first focal 2D point |
required |
foci2
|
NDArray | list
|
second focal 2D point |
required |
semi_major_axis
|
float
|
semi major axis value |
required |
n_points_polygonal_approx
|
int
|
number of points to be used in the polygonal approximation. Defaults to ContinuousGeometryEntity.DEFAULT_N_POINTS_POLYGONAL_APPROX. |
DEFAULT_N_POLY_APPROX
|
Source code in otary/geometry/continuous/shape/ellipse.py
angle(degree=False, is_y_axis_down=False)
Angle of the ellipse
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degree
|
bool
|
whether to output angle in degree, Defaults to False meaning radians. |
False
|
is_y_axis_down
|
bool
|
whether the y axis is down. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
angle value |
Source code in otary/geometry/continuous/shape/ellipse.py
copy()
Copy the current ellipse object
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
copied ellipse object |
Source code in otary/geometry/continuous/shape/ellipse.py
curvature(point)
Computes the curvature of a point on the ellipse.
Equation is based on the following where a is semi major and b is minor axis.
\kappa = \frac{1}{a^2 b^2} \left( \frac{x^2}{a^4} + \frac{y^2}{b^4} \right)^{-\frac{3}{2}}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
NDArray
|
point on the ellipse |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
curvature of the point |
Source code in otary/geometry/continuous/shape/ellipse.py
enclosing_oriented_bbox()
Enclosing oriented bounding box. Manage the case where the ellipse is a circle and return the enclosing axis-aligned bounding box in that case.
Returns:
Name | Type | Description |
---|---|---|
Rectangle |
Enclosing oriented bounding box |
Source code in otary/geometry/continuous/shape/ellipse.py
normalize(x, y)
Normalize the ellipse to a given bounding box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
float
|
width of the bounding box |
required |
y
|
float
|
height of the bounding box |
required |
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
normalized ellipse object |
Source code in otary/geometry/continuous/shape/ellipse.py
perimeter_approx(n_terms=5, is_ramanujan=False)
Perimeter approximation of the ellipse using the James Ivory infinite serie. In the case of the circle this always converges to the exact value of the circumference no matter the number of terms.
See: https://en.wikipedia.org/wiki/Ellipse#Circumference
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_terms
|
int
|
number of n first terms to calculate and add up from the infinite series. Defaults to 5. |
5
|
is_ramanujan
|
bool
|
whether to use the Ramanujan's best approximation. |
False
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
circumference approximation of the ellipse |
Source code in otary/geometry/continuous/shape/ellipse.py
polygonal_approx(n_points, is_cast_int=False)
Generate apolygonal approximation of the ellipse.
The way is done is the following: 1. suppose the ellipse centered at the origin 2. suppose the ellipse semi major axis to be parallel with the x-axis 3. compute pairs of (x, y) points that belong to the ellipse using the parametric equation of the ellipse. 4. shift all points by the same shift as the center to origin 5. rotate using the ellipse center pivot point
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_points
|
int
|
number of points that make up the ellipse polygonal approximation |
required |
is_cast_int
|
bool
|
whether to cast to int the points coordinates or not. Defaults to False |
False
|
Returns:
Name | Type | Description |
---|---|---|
Polygon |
Polygon
|
Polygon representing the ellipse as a succession of n points |
Source code in otary/geometry/continuous/shape/ellipse.py
rotate(angle, is_degree=False, is_clockwise=True, pivot=None)
Rotate the ellipse around a pivot point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle
|
float
|
angle to rotate the ellipse |
required |
is_degree
|
bool
|
whether the angle is in degrees. Defaults to False. |
False
|
is_clockwise
|
bool
|
whether the rotation is clockwise. Defaults to True. |
True
|
pivot
|
Optional[NDArray]
|
pivot point to rotate around. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
rotated ellipse object |
Source code in otary/geometry/continuous/shape/ellipse.py
shift(vector)
Shift the ellipse by a given vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector
|
NDArray
|
vector to shift the ellipse |
required |
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
shifted ellipse object |