gCAD3D 2.40
ut_rbez.c File Reference

Rational-Bezier-Curve - Utilityfunctions. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_geo.h"
#include "../ut/gr_types.h"

Functions

int UT3D_wPTn_ptn_wn (wPoint *wpa, int ptNr, Point *pta, double *wa)
 
int UT3D_pt_int_ln_rbez (int *nxp, Point *xptab, int ptxMax, Line *ln1, CurvRBez *rbez, Memspc *memSeg1, double tol)
 
int UT3D_pta_rbez (int *ptNr, Point *pTab, CurvRBez *rbez, int ptMax, double tol)
 
int UT3D_pt_intelel (int *np, Point xptab[], CurvElli *el1, CurvElli *el2, Memspc *memSeg1)
 
int UT3D_pt_intciel (int *np, Point xptab[], Circ *ci, CurvElli *el, Memspc *memSeg1)
 
int UT3D_pt_intelbspl (int *np, Point xptab[], CurvElli *el, CurvBSpl *bspl, Memspc *memSeg1)
 
int UT3D_pt_intcibspl (int *np, Point xptab[], Circ *ci, CurvBSpl *bspl, Memspc *memSeg1)
 
int UT3D_pt_int2rbez (int *nxp, Point *xptab, int ptxMax, CurvRBez *rbez1, CurvRBez *rbez2, Memspc *memSeg1, double tol)
 
int UT3D_pt_intbezrbez (int *nxp, Point *xptab, int ptxMax, CurvBez *ibcv, CurvRBez *rbez, Memspc *memSeg1, double tol)
 
int UT3D_rbez_subdiv (CurvRBez *rbez1, CurvRBez *rbez2, Memspc *memSeg1, CurvRBez *rbez, double t)
 
int UT3D_rbez_rbsp (int *tabSiz, CurvRBez **cvarb, Memspc *memSeg1, CurvRBSpl *rbsp)
 
int UT3D_rbez_el (CurvRBez rbTab[], Memspc *memSeg1, CurvElli *el)
 
int UT3D_rbez_ci_180 (int *nrCv, CurvRBez rba[], Memspc *memSeg1, Circ *ci1)
 
int UT3D_rbez_el_180 (int *nrCv, CurvRBez rba[], Memspc *memSeg1, CurvElli *el1)
 
int UT3D_rbez_180 (int *nrCv, CurvRBez rba[], Memspc *memSeg1, Point *ptc, Vector *vcx, Vector *vcy)
 
int UT3D_rbez_ci_360 (CurvRBez *rb1, Memspc *memSeg1, Circ *ci1)
 
int UT3D_rbez_el_360 (CurvRBez *rb1, Memspc *memSeg1, CurvElli *el1)
 
int UT3D_rbez_360 (CurvRBez *rb1, Memspc *memSeg1, Point *ptc, Vector *vcx, Vector *vcy)
 
int UT3D_rbez_ci__ (int *nrCv, CurvRBez rba[], Memspc *memSeg1, Circ *ci)
 

Detailed Description

Rational-Bezier-Curve - Utilityfunctions.

=====================================================
List_functions_start:
UT3D_pt_intelel intersection ellipse - ellipse
UT3D_pt_intciel intersection circle - ellipse
UT3D_pt_intelbspl intersection ellipse - B-spline
UT3D_pt_intcibspl intersection circle - B-spline
UT3D_pta_rbez make Polygon from rational-bezier-curve
UT3D_pt_int_ln_rbez intersect line X rational-bezier-curve
UT3D_pt_int2rbez intersect 2 rational Bezier curves
UT3D_pt_intbezrbez intersect integral - rational Bezier curve
UT3D_rbez_ci_0
UT3D_rbez_el rational quadratic Bezier curves <-- 3D-ellipse
UT3D_rbez_rbsp rational-bezier-curve from rational-B-spline
UT3D_rbez_subdiv subdivide rational Bezier curve
UT3D_wPTn_ptn_wn get wPoint-array from controlpoints and weights
List_functions_end:
=====================================================

Function Documentation

int UT3D_wPTn_ptn_wn ( wPoint wpa,
int  ptNr,
Point pta,
double *  wa 
)
* UT3D_wPTn_ptn_wn get wPoint-array from controlpoints and weights
* DOES MULTIPLY COORDS X WEIGHT
*
int UT3D_pt_int_ln_rbez ( int *  nxp,
Point xptab,
int  ptxMax,
Line ln1,
CurvRBez rbez,
Memspc memSeg1,
double  tol 
)
int UT3D_pta_rbez ( int *  ptNr,
Point pTab,
CurvRBez rbez,
int  ptMax,
double  tol 
)
int UT3D_pt_intelel ( int *  np,
Point  xptab[],
CurvElli el1,
CurvElli el2,
Memspc memSeg1 
)
int UT3D_pt_intciel ( int *  np,
Point  xptab[],
Circ ci,
CurvElli el,
Memspc memSeg1 
)
int UT3D_pt_intelbspl ( int *  np,
Point  xptab[],
CurvElli el,
CurvBSpl bspl,
Memspc memSeg1 
)
int UT3D_pt_intcibspl ( int *  np,
Point  xptab[],
Circ ci,
CurvBSpl bspl,
Memspc memSeg1 
)
int UT3D_pt_int2rbez ( int *  nxp,
Point xptab,
int  ptxMax,
CurvRBez rbez1,
CurvRBez rbez2,
Memspc memSeg1,
double  tol 
)
int UT3D_pt_intbezrbez ( int *  nxp,
Point xptab,
int  ptxMax,
CurvBez ibcv,
CurvRBez rbez,
Memspc memSeg1,
double  tol 
)
int UT3D_rbez_subdiv ( CurvRBez rbez1,
CurvRBez rbez2,
Memspc memSeg1,
CurvRBez rbez,
double  t 
)
int UT3D_rbez_rbsp ( int *  tabSiz,
CurvRBez **  cvarb,
Memspc memSeg1,
CurvRBSpl rbsp 
)
* UT3D_rbez_rbsp rational-bezier-curve from rational-B-spline
* Backmeister, Reiter 2014-09-11
* save all output-curves (rbTab) in memSeg1
*
int UT3D_rbez_el ( CurvRBez  rbTab[],
Memspc memSeg1,
CurvElli el 
)
int UT3D_rbez_ci_180 ( int *  nrCv,
CurvRBez  rba[],
Memspc memSeg1,
Circ ci1 
)
int UT3D_rbez_el_180 ( int *  nrCv,
CurvRBez  rba[],
Memspc memSeg1,
CurvElli el1 
)
int UT3D_rbez_180 ( int *  nrCv,
CurvRBez  rba[],
Memspc memSeg1,
Point ptc,
Vector vcx,
Vector vcy 
)
UT3D_rbez_180 rational-bezier-curve for 180- or 360-deg-curve
Circle or ellipse.
IN:
Memspc *memSeg1 ... receives controlpoints and weights
Circ *ci ... 3D-circle
OUT:
nrCv ... nr of curves out; 1 or 2.
CurvRBez rba ... rational Bezier curves, each having a 180 deg. circ.
int UT3D_rbez_ci_360 ( CurvRBez rb1,
Memspc memSeg1,
Circ ci1 
)
int UT3D_rbez_el_360 ( CurvRBez rb1,
Memspc memSeg1,
CurvElli el1 
)
int UT3D_rbez_360 ( CurvRBez rb1,
Memspc memSeg1,
Point ptc,
Vector vcx,
Vector vcy 
)
*
* UT3D_rbez_ci_360 rational Bezier curves for 360-deg-circ
*
* IN:
* Memspc *memSeg1 ... receives controlpoints and weights
* Circ *ci ... 3D-circle
* OUT:
* CurvRBez *rb1 ... 1 rational Bezier curve with 6 points
Point pt0, pt1, pt2, pt3, pt4;
// provide memory for ncp controlpoints
rb1->cptab = UME_reserve (memSeg1, sizeof(Point) * 6);
if(!rb1->cptab) goto L_err1;
// provide memory for ncp weights
rb1->wtab = UME_reserve (memSeg1, sizeof(double) * 6);
if(!rb1->wtab) goto L_err1;
// pt0 = ptc + vcx;
UT3D_pt_traptmultvc (&pt0, ptc, vcx, 1.);
// pt1 = ptc + vcx + (4 * vcy)
UT3D_pt_traptvc (&pt1, ptc, vcx);
UT3D_pt_traptmultvc (&pt1, &pt1, vcy, 4.);
// pt2 = ptc + (-3 * vcx) + (2 * vcy)
UT3D_pt_traptmultvc (&pt2, ptc, vcx, -3.);
UT3D_pt_traptmultvc (&pt2, &pt2, vcy, 2.);
// pt3 = mirr. pt2
// pt3 = ptc + (-3 * vcx) + (-2 * vcy)
UT3D_pt_traptmultvc (&pt3, ptc, vcx, -3.);
UT3D_pt_traptmultvc (&pt3, &pt3, vcy, -2.);
// pt4 = mirr. pt1
// pt1 = ptc + vcx + (-4 * vcy)
UT3D_pt_traptvc (&pt4, ptc, vcx);
UT3D_pt_traptmultvc (&pt4, &pt4, vcy, -4.);
// UT3D_pt_3db (&pt0, 100., 0., 0.);
// UT3D_pt_3db (&pt1, 100., 400., 0.);
// UT3D_pt_3db (&pt2, -300., 200., 0.);
// UT3D_pt_3db (&pt3, -300., -200., 0.);
// UT3D_pt_3db (&pt4, 100., -400., 0.);
rb1->ptNr = 6;
rb1->va = 0.;
rb1->vb = 1.;
rb1->cptab[0] = pt0;
rb1->cptab[1] = pt1;
rb1->cptab[2] = pt2;
rb1->cptab[3] = pt3;
rb1->cptab[4] = pt4;
rb1->cptab[5] = pt0;
rb1->wtab[0] = 5.;
rb1->wtab[1] = 1.;
rb1->wtab[2] = 1.;
rb1->wtab[3] = 1.;
rb1->wtab[4] = 1.;
rb1->wtab[5] = 5.;
// UT3D_stru_dump (Typ_CVRBEZ, rb1, "UT3D_rbez_360");
// { long dli = -1L; //GL_Draw_rbez (&dli, 1, rb1); }
// GR_Disp_rbez (rb1, 1); }
return 0;
L_err1:
TX_Error("UT3D_rbez_360: out of memspace");
return -1;
}
//============================================================================
int UT3D_rbez_ci_0 (int *nrCv, CurvRBez rba[], Memspc *memSeg1, Circ *ci1) {
//============================================================================
* \code
* UT3D_rbez_ci_0 rational-bezier-curve for circle (0-120 deg max)
*
* IN:
* Memspc *memSeg1 ... receives controlpoints and weights
* Circ *ci ... 3D-circle
* OUT:
* nrCv ... number of ouput-curves
* CurvRBez rb1 ... quadratic rational-bezier-curves
*
int UT3D_rbez_ci__ ( int *  nrCv,
CurvRBez  rba[],
Memspc memSeg1,
Circ ci 
)
*
* UT3D_rbez_ci__ rational Bezier curves <-- 3D-circle
*
* Conversion of a 3D-circle into rational Bezier curves.
* The Bezier curves have POSITIVE weights.
*
* IN:
* Memspc *memSeg1 ... receives controlpoints and weights
* Circ *ci ... 3D-circle
* OUT:
* CurvRBez rbTab[] ... 1-3 rational Bezier curves
* Returncodes:
* 0 = OK
* -1 = out of tempSpace
*
*