gCAD3D 2.35
ut_elli.c File Reference

ellipse More...

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_geo.h"
#include "../ut/ut_math.h"
#include "../ut/func_types.h"
#include "../ut/ut_elli.h"

Functions

int UT3D_pt_ell_lim_del (int *nrp, Point *pa, double *va1, CurvElli *cv1)
 
double UT3D_lne_ell (CurvElli *el1)
 
int UT3D_el_ci (CurvElli *eo, Circ *ci)
 
int UT3D_el_inv1 (CurvElli *el1)
 
int UT3D_el_inv2 (CurvElli *el1)
 
double UT3D_angr_par1_ell (double par1, CurvElli *el1)
 
int UT3D_ck_el360 (CurvElli *el1)
 
int UT3D_el_elpt180 (CurvElli *el1, Point *p1)
 
int UT3D_el_el2pt (CurvElli *el1, Point *p1, Point *p2)
 
double UT3D_angr_elpt (Point *pti, Point *ptc, Vector *va, Vector *vb)
 
int UT3D_ptvc_eval_ell_par (Point *pto, Vector *vct, CurvElli *el1, int pTyp, double par)
 
int UT3D_pt_eval_ell_par1 (Point *pto, CurvElli *el1, double par1)
 
int UT3D_pt_elangd (Point *pto, Point *ptc, Vector *va, Vector *vb, double angr)
 
int UT2D_pt_elangd (Point2 *pto, double lx, double ly, double angr)
 
int UT3D_el_ptc_ptx_pt (CurvElli *el1, Point *ptc, Point *ptx, Point *pt1)
 
int UT3D_el_pt2vc2a (CurvElli *el, Point *ptc, Vector *vcx, Vector *vcy, double a1, double a2, int idir)
 
int UT3D_pt_ck_onel (Point *pt, CurvElli *el)
 
int UT3D_pt_elfoc (Point *fp1, Point *fp2, CurvElli *el)
 
int UT2D_vc_tang_el2 (Vector2 *vct, Point2 *pt1, CurvEll2 *el2)
 
int UT2D_vc_tang_elc (Vector2 *vc21, Point2 *p21, double da)
 
int UT3D_vc_tangel (Vector *vc1, Point *pt1, CurvElli *el1)
 
int UT3D_ptNr_ell (CurvElli *el3, double tol)
 
double UT3D_angr_el_corr (double aa, double da, double db)
 
int UT3D_npt_ell (int ptNr, Point *pa, CurvElli *el3)
 
int UT3D_el_projelpl (CurvElli *elo, Plane *pl, CurvElli *eli)
 
int UT3D_el_projcipl (CurvElli *el, Plane *pl, Circ *ci)
 
int UT3D_pt_projptel (int *numpe, Point *pe, CurvElli *ell, Point *pt)
 
int UT3D_el_elcoe (CurvElli *obj, polcoeff_d5 *ec, Point2 *pa, Point2 *pe, double zt)
 
int UT3D_elcoe_el (polcoeff_d5 *ig, CurvElli *el)
 
int UT3D_pt_intplell (int *pNr, Point *pa, Plane *pln, CurvElli *el)
 
int UT3D_pt_intlnel__ (int *np, Point xp[], Line *ln, CurvElli *el)
 
int UT3D_pt_intlnel_p (int *np, Point xp[], Line *ln, CurvElli *el)
 
int UT2D_pt_int_elc_ln (Point2 *p1, Point2 *p2, Line2 *ln1, CurvEll2C *el1)
 
int UT3D_vc_tng_elpt__ (Vector *vco, Point *pt1, CurvElli *el1, int isol)
 
int UT3D_vc_tng_elptMaj (Vector *vco, Point *pt1, CurvElli *el1, int sid, int isol)
 
int UT3D_vc_tng_elptMin (Vector *vco, Point *pt1, CurvElli *el1, int sid, int isol)
 
int UT3D_pt_el_ptx (double *dye, double dx, double a, double b)
 
int UT3D_pt_el_pty (double *dxe, double dy, double a, double b)
 
int UT2D_pt_tng_ell_vc (Point2 *pto, Vector2 *vct, CurvEll2 *cv1, int isol)
 
int UT2D_pt_el_ptx (double *dye, double dx, double a, double b)
 
int UT2D_pt_el_pty (double *dxe, double dy, double a, double b)
 
int UT2D_pt_tng_ell_ptMaj (Point2 *ptg, Point2 *pt1, CurvEll2 *el1, int sid, int isol)
 
int UT2D_pt_tng_ell_ptMin (Point2 *ptg, Point2 *pt1, CurvEll2 *el1, int sid, int isol)
 
int UT2D_pt_tng_ell_pt (Point2 *ptg, CurvEll2 *el1, Point2 *pt1, int isol)
 
int UT2D_angr_elc_pt (double *aa, Point2 *p1, CurvEll2C *elc)
 
int UT2D_2angr_el (double *angs, double *ango, CurvEll2C *el2c)
 
int UT2D_elc_el3 (CurvEll2C *el2c, CurvElli *el3)
 
int UT2D_pt_ptel3 (Point2 *pt2, Point *pt3, CurvElli *el3)
 
int UT3D_par1_el_pt (double *du, CurvElli *el1, Point *pt1)
 

Detailed Description

ellipse

=====================================================
List_functions_start:
UT3D_ptNr_ell get nr of points for ellipse
UT3D_npt_ell polygon from ellipse, fixed nr of points
UT3D_par1_el_pt get parameter (0-1) for point on ellipse
UT3D_par1_angr_ell UU parametric-Angle --> par 0-1
UT3D_ck_el360 check if elli is 360-degree-elli
UT3D_angr_par1_ell par 0-1 --> parametric-Angle
UT3D_angr_elpt real angle for point on elli
UT3D_angr_el_corr get angle-circ from angle of elli.
UT2D_2angr_el get starting- and opening angle of ellipse
UT3D_ango_el UU opening angle of ellipse
UT3D_lne_ell get dist center-focus for ellipse
UT3D_pt_ell_lim_del remove points outside limited ellipse
UT3D_ptvc_eval_ell_par get point/tangentVector on ellipse from parameter
UT3D_pt_eval_ell_par1 pt <- parametric-Angle (0-1)
UT3D_pt_elangd pt <- parametric-Angle.
UT3D_pt_ck_onel check if point lies on an (full) ellipse
UT3D_pt_elfoc focal points of ellipse
UT3D_pt_projptel proj PT -> CRV-Ellipse
UT3D_pt_el_ptx get y-coord of point on elli
UT3D_pt_el_pty get x-coord of point on elli
UT3D_pt_intlnel__ intersect line and ellipse
UT3D_pt_intlnel_p intersection LN-ELL (gives 0/1/2 points)
UT3D_pt_intplell intersect plane ellipse
UT3D_vc_tangel tangent thru point ON ellipse
UT3D_pt_tng_ell_vc__ tangents vector-ellipse. DO NOT USE
UT3D_vc_tng_elpt__ tangents point-ellipse DO NOT USE
UT3D_vc_tng_elptMaj tangents point-ellipse; point on majorAxis DO NOT USE
UT3D_vc_tng_elptMin tangents point-ellipse; point on minorAxis DO NOT USE
UT3D_el_ptc_ptx_pt elli from centerPt,endPtMajAxis,ptOnElli.
UT3D_el_pt2vc2a elli=center,vecMajAx,vecMinAx,AngStart,angEnd,dir.
UT3D_el_ci change circ > ellipse
UT3D_el_projelpl ellipse = project ELL -> PLN
UT3D_el_projcipl ellipse = project CIR -> PLN
UT3D_el_elcoe Ellipse <-- coeff-data (IGES)
UT3D_el_elpt180 change elli -> 180 deg-elli; keep dir
UT3D_el_el2pt change start- and endpoint of elli
UT3D_elcoe_el CoeffEllipse(IGES) <-- ellipse
UT3D_el_inv1 turn direction and p1/p2 (same display !)
UT3D_el_inv2 turn direction (do not swap p1,p2)
-------------- CurvEll2C -------------------------------------
UT2D_elc_el3 make 2D-ell in centerPos from 3D-ell
UT2D_angr_elc_pt get angle for point on 2D-elli in centerPos.
UT2D_pt_el_ptx get y-coord of point on elli
UT2D_pt_el_pty get x-coord of point on elli
UT2D_pt_elangd pt from angle, rMaj, rMin.
UT2D_vc_tang_el2 tangent thru point ON 2D-ellipse
UT2D_vc_tang_elc tangent thru point ON 2D-ellipse/centerPos
UT2D_pt_int_elc_ln intersection of ellipse - line (ell.in centerPos)
UT2D_pt_tng_ell_vc get tangent vector-ellipse.
UT2D_pt_tng_ell_pt get tangent point-ellipse.
UT2D_pt_tng_ell_ptMaj tangents point-ellipse; point on majorAxis
UT2D_pt_tng_ell_ptMin tangents point-ellipse; point on minorAxis
List_functions_end:
=====================================================

Function Documentation

int UT3D_pt_ell_lim_del ( int *  nrp,
Point pa,
double *  va1,
CurvElli cv1 
)
UT3D_pt_ell_lim_del remove points outside limited ellipse
Input:
nrp nr of points on unlimited ellipse cv1
pa points
va1 size nrp, can be empty or NULL
Output:
nrp nr of points inside trimmed ellipse cv1
va1 parameter on points;
double UT3D_lne_ell ( CurvElli el1)

UT3D_lne_ell get dist center-focus for ellipse

int UT3D_el_ci ( CurvElli eo,
Circ ci 
)
change circ > ellipse
vz of circ must have length=1 !
int UT3D_el_inv1 ( CurvElli el1)
int UT3D_el_inv2 ( CurvElli el1)

UT3D_el_inv2 turn direction (do not swap p1,p2)

double UT3D_angr_par1_ell ( double  par1,
CurvElli el1 
)
UT3D_angr_par1_ell par 0-1 --> angle
par1 always 0-1 (relative); if el1 is relimited to 0deg-90deg, then
par1=0.5 gives 45deg.
par_Angle = StartAngle + (OpeningAngle * par1)
int UT3D_ck_el360 ( CurvElli el1)
UT3D_ck_el360 check if elli is 360-degree-elli
RC = 1: NO
RC = 0: YES, is 360-deg-elli
RC = -2: degenerated
if(UT3D_ck_el360 == YES) ...
int UT3D_el_elpt180 ( CurvElli el1,
Point p1 
)
int UT3D_el_el2pt ( CurvElli el1,
Point p1,
Point p2 
)

UT3D_el_el2pt change start- and endpoint of elli

double UT3D_angr_elpt ( Point pti,
Point ptc,
Vector va,
Vector vb 
)
UT3D_angr_elpt real angle for point on elli
real angle (not angle on innerCircle. Used for dxf).
int UT3D_ptvc_eval_ell_par ( Point pto,
Vector vct,
CurvElli el1,
int  pTyp,
double  par 
)
UT3D_ptvc_eval_ell_par get point/tangentVector on ellipse from parameter
Input:
pto point; NULL for no output
vct tangent-vector; NULL for no output
pTyp type of parameter;
0=normalized parameter (0-1)
1=native parameter (angle); any value ..
int UT3D_pt_eval_ell_par1 ( Point pto,
CurvElli el1,
double  par1 
)
UT3D_pt_eval_ell_par1 get point on ellipse from parameter 0-1
par1 parameter; 0-1
int UT3D_pt_elangd ( Point pto,
Point ptc,
Vector va,
Vector vb,
double  angr 
)

UT3D_pt_elangd pt <- parametric-Angle. Input: angr in rad

int UT2D_pt_elangd ( Point2 pto,
double  lx,
double  ly,
double  angr 
)
UT2D_pt_elangd pt from angle, rMaj, rMin.
get point on ellipse from angle and length of axes.
Input:
angr angle in rad
lx length major axis
ly length minor axis
int UT3D_el_ptc_ptx_pt ( CurvElli el1,
Point ptc,
Point ptx,
Point pt1 
)

UT3D_el_ptc_ptx_pt elli from centerPt,endPtMajAxis,ptOnElli.

int UT3D_el_pt2vc2a ( CurvElli el,
Point ptc,
Vector vcx,
Vector vcy,
double  a1,
double  a2,
int  idir 
)
UT3D_el_pt2vc2a elli=center,vecMajAx,vecMinAx,AngStart,angEnd,dir.
idir: CCW (0) od CW(1)
int UT3D_pt_ck_onel ( Point pt,
CurvElli el 
)
UT3D_pt_ck_onel check if point lies on an (full) ellipse
Check if a point lies on an (full) ellipse.
It is assumed that the point lies in the plane of the ellipse.
IN:
Point *pt ... 3D-point
CurvElli *el ... 3D-ellipse
OUT:
Returncodes:
0 = point is not on the ellipse
1 = point is on the ellipse
-1 = internal error
int UT3D_pt_elfoc ( Point fp1,
Point fp2,
CurvElli el 
)
UT3D_pt_elfoc focal points of ellipse
Computation of the focal points of an ellipse.
IN:
CurvElli *el ... 3D-ellipse
OUT:
Point *fp1 focal point 1 (in direction of main axis); NULL = none
Point *fp2 focal point 2 NULL = none
Returncodes:
0 = OK
-1 = input error
int UT2D_vc_tang_el2 ( Vector2 vct,
Point2 pt1,
CurvEll2 el2 
)

UT2D_vc_tang_el2 tangent thru point ON 2D-ellipse

int UT2D_vc_tang_elc ( Vector2 vc21,
Point2 p21,
double  da 
)

UT2D_vc_tang_elc tangent thru point ON 2D-ellipse/centerPos da major length

int UT3D_vc_tangel ( Vector vc1,
Point pt1,
CurvElli el1 
)

UT3D_vc_tangel tangent thru point ON ellipse

int UT3D_ptNr_ell ( CurvElli el3,
double  tol 
)
double UT3D_angr_el_corr ( double  aa,
double  da,
double  db 
)
UT3D_angr_el_corr get angle-circ from angle of elli.
compute point on elli from corrected angle with sin|cos * lmay|lmin
int UT3D_npt_ell ( int  ptNr,
Point pa,
CurvElli el3 
)
int UT3D_el_projelpl ( CurvElli elo,
Plane pl,
CurvElli eli 
)
UT3D_el_projelpl ellipse = project ELL -> PLN
int UT3D_el_projcipl ( CurvElli el,
Plane pl,
Circ ci 
)
UT3D_el_projcipl ellipse = project CIR -> PLN
Project a circle onto a plane.
IN:
Plane *pl ... projection plane
Circ *ci ... 3D - circle
OUT:
CurvElli *el ... ellipse
Returncodes:
0 = OK
see also UPRJ_app_el
int UT3D_pt_projptel ( int *  numpe,
Point pe,
CurvElli ell,
Point pt 
)
UT3D_pt_projptel proj PT -> CRV-Ellipse
Project a point onto an ellipse.
All possible cases are considered!
IN:
CurvElli *ell ... a 3D - ellipse
Point *pt ... a 3D - point
OUT:
int *numpe ... number of points (0-4 points out)
Point *pe ... points on the ellipse all having the same minimal
distance to the input point
Returncodes:
0 = OK
1 = input error
TODO: gives only one solution !
int UT3D_el_elcoe ( CurvElli obj,
polcoeff_d5 ec,
Point2 pa,
Point2 pe,
double  zt 
)
UT3D_el_elcoe Ellipse <-- coeff-data (IGES)
ellipse from IGES-data of type 104.
pa,pe Beginn/Endpunkt der Elli in 2D-Zentrumslage (Center ist 0,0)
zt = Hoehe der Z-Plane der Elli im 2D
IN:
IgesConic *ig ... IGES-data of type 104 (conic arc entity)
OUT:
Ellipse
Returncodes:
0 = OK and conic is ellipse
-1 = input error: data are no conic arc entity
int UT3D_elcoe_el ( polcoeff_d5 ig,
CurvElli el 
)
UT3D_elcoe_el CoeffEllipse(IGES) <-- ellipse
the ellipse lies in a plane parallel x,y-plane and its axes need not be
parallel to x- resp. y- axis.
IN:
CurvElli *el ... ellipse in a plane parallel x,y-plane
OUT:
polcoeff_d5 ... IGES-coefficients of the ellipse equation
Returncode:
0 = OK
-1 = input error
int UT3D_pt_intplell ( int *  pNr,
Point pa,
Plane pln,
CurvElli el 
)

UT3D_pt_intplell intersect plane ellipse

int UT3D_pt_intlnel__ ( int *  np,
Point  xp[],
Line ln,
CurvElli el 
)
UT3D_pt_intlnel__ intersect (unlim.) line and ellipse
Intersection of line and ellipse.
The line need NOT lie in the plane of the ellipse.
IN:
Line *ln ... 3D-line
CurvElli *el ... 3D-ellipse
OUT:
int *np ... number of intersection points (0,1,2)
Point xp[] ... array of intersection points
Returncodes:
0 = OK
1 = no intersection
-1 = ellipse degenerated
int UT3D_pt_intlnel_p ( int *  np,
Point  xp[],
Line ln,
CurvElli el 
)
UT3D_pt_intlnel_p intersection LN-ELL (gives 0/1/2 points)
both unlimited !
!! The line must lie in the plane of the ellipse. !!
Intersection of 3D-line with 3D-ellipse.
!! The line must lie in the plane of the ellipse. !!
IN:
Line *ln ... 3D-line
CurvElli *el ... 3D-ellipse
OUT:
int *np ... number of intersection points (0,1,2)
Point xp[] ... array of intersection points
Returncodes:
0 = OK
1 = no intersection
-1 = ellipse degenerated
int UT2D_pt_int_elc_ln ( Point2 p1,
Point2 p2,
Line2 ln1,
CurvEll2C el1 
)
int UT3D_vc_tng_elpt__ ( Vector vco,
Point pt1,
CurvElli el1,
int  isol 
)
UT3D_vc_tng_elpt tangents point - ellipse
2013-04-17 Backmeister-Reiter
Input:
isol 0=solution-1; 1=solution-2;
RetCod:
1 OK, point is on ellipse
0 OK, point is outside ellipse
-1 Error: pt1 inside ellipse
int UT3D_vc_tng_elptMaj ( Vector vco,
Point pt1,
CurvElli el1,
int  sid,
int  isol 
)

UT3D_vc_tng_elptMaj tangents point-ellipse; point on majorAxis 2013-04-18 Reiter

RetCod: 1 OK, point is on ellipse 0 OK, point is outside ellipse -1 Error: pt1 inside ellipse

int UT3D_vc_tng_elptMin ( Vector vco,
Point pt1,
CurvElli el1,
int  sid,
int  isol 
)

UT3D_vc_tng_elpt tangents point-ellipse; point on minorAxis 2013-04-18 Reiter

RetCod: 1 OK, point is on ellipse 0 OK, point is outside ellipse -1 Error: pt1 inside ellipse

int UT3D_pt_el_ptx ( double *  dye,
double  dx,
double  a,
double  b 
)
int UT3D_pt_el_pty ( double *  dxe,
double  dy,
double  a,
double  b 
)
int UT2D_pt_tng_ell_vc ( Point2 pto,
Vector2 vct,
CurvEll2 cv1,
int  isol 
)
get tangent vector-ellipse.
ellipse and vector must be planar to constr.Plane.
isol 0=solution-1; 1=solution-2;
2013-04-23 Backmeister, Reiter
0 OK
-1 Error isol
-2 internal error
-3 EOM
int UT2D_pt_el_ptx ( double *  dye,
double  dx,
double  a,
double  b 
)
int UT2D_pt_el_pty ( double *  dxe,
double  dy,
double  a,
double  b 
)
int UT2D_pt_tng_ell_ptMaj ( Point2 ptg,
Point2 pt1,
CurvEll2 el1,
int  sid,
int  isol 
)

UT3D_vc_tng_elptMaj tangents point-ellipse; point on majorAxis 2013-04-18 Reiter isol 0|1

RetCod: 1 OK, point is on ellipse 0 OK, point is outside ellipse -1 Error: pt1 inside ellipse

int UT2D_pt_tng_ell_ptMin ( Point2 ptg,
Point2 pt1,
CurvEll2 el1,
int  sid,
int  isol 
)

UT3D_vc_tng_elpt tangents point-ellipse; point on minorAxis 2013-04-18 Reiter isol 0|1

RetCod: 1 OK, point is on ellipse 0 OK, point is outside ellipse -1 Error: pt1 inside ellipse

int UT2D_pt_tng_ell_pt ( Point2 ptg,
CurvEll2 el1,
Point2 pt1,
int  isol 
)

get tangent point-ellipse. isol 0=solution-1; 1=solution-2; 2013-04-20 Reiter 1 OK, point is on ellipse 0 OK, point is not on ellipse -2 internal error -3 EOM

int UT2D_angr_elc_pt ( double *  aa,
Point2 p1,
CurvEll2C elc 
)
UT2D_angr_elc_pt get angle for point on 2D-elli in centerPos.
returns the real-angle between the major-axis and p1
int UT2D_2angr_el ( double *  angs,
double *  ango,
CurvEll2C el2c 
)
UT2D_2angr_el get starting- and opening angle of ellipse
angs real-angle between major-axis and startpoint
ango real-opening-angle between startpoint and endpoint
CCW ?
int UT2D_elc_el3 ( CurvEll2C el2c,
CurvElli el3 
)
int UT2D_pt_ptel3 ( Point2 pt2,
Point pt3,
CurvElli el3 
)

UT2D_pt_ptel3 get pt on 2D-elli in centerPos from pt on 3D-elli

int UT3D_par1_el_pt ( double *  du,
CurvElli el1,
Point pt1 
)