Presentation - COMPUTATIONAL GEOMETRY FOR MACHINING
Presentation - COMPUTATIONAL GEOMETRY FOR MACHINING
Chang
COMPUTATIONAL GEOMETRY
FOR MACHINING
and
04/19/20 10 - 1
©T.C. Chang
x = x1 + ( x2 – x1)t
0 t 1
y = 1y + ( 2y – 1y)t
Circle: x = cos t
0 t2
y = r 2 – x2 x2 + y2 – r 2 = 0 y = sin t
Tangent:
d (f x1)
y = 1y + ( x – x1 )
dx
Normal:
y = 1y – ( x – x1 ) 1 d f( x1)
dx
04/19/20 10 - 2
©T.C. Chang
TANGENT AND
NORMAL
Tangent of a parametric curve:
x = x(t) 0t 1
Curve: y = y( t)
0 t 1 or r(t)
Tangent vector: T = ( x, y)
x = dx(t) dt
y = dy(t) dt
N
Tangent line T
x = x(t) + x(t) r(t1)
–
y = y( t) + y( t)
Uni-normal vector:
U = N N = x2 + y2
N
04/19/20 10 - 3
©T.C. Chang
CUTTER OFFSET
N
T Cutter diameter = d
CL at r(t1) is:
r(t1) + d U = r(t1) + d N
2 2 N
04/19/20 10 - 4
©T.C. Chang
VECTOR PRODUCTS
a = a1 i + a2 j+ a3 k
b = b1 i + b2 j+ b3 k
a
= (a2 b3 – a3 b2) i +
(a3 b1 – a1 b3) j + bxa
(a1 b3 – a2 b1) k
04/19/20 10 - 5
©T.C. Chang
MAPT LANGUAGE
User program
in MAPT
MAPT
MAPT LEX parser
grammar &
YACC MAPT
Language
Math processor Processor
Output
formatter
04/19/20 10 - 6
©T.C. Chang
MAPT
GRAMMAR
Defining a point in YACC:
point_spec : coord_spec {
$$.X = $1.X; | xy_large_small ',' INTOF ',' circledef ','
$$.y = $1.y; circledef
$$.z = $1.z; } {
| linedef ',' linedef i = (int)$1;
{ j = (int)$5;
i = (int)$1; k = (int)$7;
j = (int)$3; gpt2cir(i,j,k,&$$); }
gp2line(i,j,&$$); } | xy_large_small ',' INTOF ',' linedef ',' circledef
| pointdef ',' coord_spec {
{ i = (int)$1;
j = (int)$5;
i = (int)$1;
k = (int)$7;
$$.x = pxyz[i].x + $3.x;
gptlncir(i,j,k,&$$);
$$.y = pxyz[i].y + $3.y;
}
$$.z = pxyz[i].z + $3.z; }
;
| CENTER ',' circledef
{
i = (int)$3;
$$.x = cirxyr[i].x;
$$.y = cirxyr[i].y;
$$.z = 0.; }
04/19/20 10 - 7
©T.C. Chang
DATA
typedef struct circletype {STRUCTURES
typedef struct planetype {
double x; double a;
double y; double b;
double r; double c;
} circletype, *circlePtr; double d;
} planetype, *planePtr;
typedef struct linetype {
double x1; typedef struct pocketype {
double y1; struct pocketype * prev;
double z1; struct pocketype * next;
double x2; int type;
double y2; double x;
double z2; double y;
} linetype, *linePtr; double z;
} pocketype;
typedef struct pointtype {
double x;
double y;
double z;
} pointtype, *pointPtr;
04/19/20 10 - 8
©T.C. Chang
PARSIN
e.g.
G
token - symbol
P-name = POINT/x,y,z
04/19/20 10 - 9
©T.C. Chang
(x1 , y1 ) (x 2, y2)
x –x x –x
l 1 : y – y1 = y2 – y1 l1 l2
line 1: 1 2 1
(x3 , y3 ) (x 4, y4) x –x x –x
line 2: l 2 : y – y3 = y4 – y3
3 4 3
x –x x –x
let: a = y2 – y1 b = y4 – y3
2 1 4 3
Problems:
x –x x –x
l 1 : y – y1 = a l 2 : y – y3 = b
1 3 a = b : parallel lines, no solution
x – x 1 = a ( y – y1) (1) overflow in equation
x – x 3 = b ( y – y3) (2) y2 = y1 : l1 parallel to the x-axis.
(1) – (2) x3 – x1 = (a–b) y+ (a y1 – by3) "a" is infinite
(a–b) y = (x 3 – x1) – (a y1 – by3)
a b
y2 y1
(x 3 – x1 ) – (a y1 – by 3)
y=
(a–b)
x = a ( y – y1 ) + x1
04/19/20 10 - 10
©T.C. Chang
MOTION STATEMENTS
GO{LFT,RGT}/L1,{TO,ON,PAST}, L2
l1
ON is easy, it is the
intersection
TO & PAST need offset
l2
04/19/20 10 - 11
©T.C. Chang
MOTION STATEMENTS
What if this is always the case:
y
x = 0.0 l2
y = y * – r (0.,y*)
sin
(x,y)
l1
y = y * + flag r
sin
x
– 1 To
flag= 0 On
1 Past
04/19/20 10 - 12
©T.C. Chang
USE TRANSFORMATION
We can make every problem as simple as the one shown before through
a transformation.
ANOTHER EXAMPLE
{GOLFT, GORGT} / L1, {TO,ON,PAST} , C1
04/19/20 10 - 14
©T.C. Chang
3D CURVES AND
SURFACES
Parametric description of a curve.
r( t ) r = r( t) tmin t tmax
Z
Y
x = x(t)
X
y = y(t)
z = z(t)
r( t , s )
04/19/20 10 - 15
©T.C. Chang
TANGENT AND
T =dr
NORMAL
is the tangent vector of curve r(t).
dt
s
t
04/19/20 10 - 16
©T.C. Chang
CUTTER OFFSET
In 3-axis machining, the surface normal passes through the tool center.
CL = CC + d N
2 N
= r(t,s) + d N
2 N N
CL
CC
s
t
04/19/20 10 - 17
©T.C. Chang
SCULPTURED SURFACE
MACHINING
3-AXIS MACHINING - ball-end mill
5-AXIS MACHINING - flat-end mill, or filleted flat-end mill
Ball-end mills for 3-axis machining Flat-end & filleted flat-end mills
3-axis machining
fixed tool orientation 5-axis machining
change tool orientation
04/19/20 10 - 18
©T.C. Chang
CARTESIAN
CUTTING
s
t Interpolate on the surface based
Y
on the straight path on the X-Y
plane.
cutter path Difficult to solve the intersection
between a Cartesian equation
and a parametric equation.
y=a
r(t,s)
X
04/19/20 10 - 19
©T.C. Chang
ISOPARAMETER
MACHINING
04/19/20 10 - 20
©T.C. Chang
FORWARD STEPPING
Move on the u direction first. Use step size u.
= ui + u
ui+1
N(ui+1,v )j
rCL = r(ui+1,v )j + dia
2 N(u ,v )
i+1 j
is the CL point
surface normal
ui+1 curve
e r(u,v )j
ui
e Š tolerance value
u
04/19/20 10 - 21
©T.C. Chang
SIDE STEPPING
Take a side step before moving on the next curve segment.
Side step v
v
vi+1 = vi + v
v u
v
Repeat forward stepping and side stepping until the entire surface
is machined.
04/19/20 10 - 22
©T.C. Chang
STEP SIZE
A quick and dirty approach:
Set an initial u, find the maximum cordal deviation. If the deviation is greater
than the tolerance, reduce u, and try again. Otherwise, the next step is found.
r(ui+ u)
r(ui)
= ui + u
ui+1
If max(d) > tolerance, set u, = 0.75 u, repeat the above step.
Otherwise stop.
04/19/20 10 - 23
©T.C. Chang
SIDE STEP
l = |r(vi + 1 – r(vi)|
r(vi +1)
r(vi ) l
vi+1 = vi + v dia/2
If > tolerance v = 0.75 v
and repeat, otherwise stop
dia – 2
( dia ) – ( l )
2
2 2 2
04/19/20 10 - 24
©T.C. Chang
over estimate
under estimate
Convex surface Concave surface
vi+1 curve
tolerance
vi curve
tolerance
UTILITY CODES -
Point/line distance/Y angle
#include <math.h>
#include <stdio.h> /* find the angle between a line and the y axis */
#define eps1 0.00001 double
#define pi 3.1415 yangl(x1,y1,x2,y2)
double x1, y1, x2, y2;
typedef struct linetype { {
double x1; double dx, dy,ang;
double y1;
double z1; dx = x2 - x1;
double x2; dy = y2 - y1;
double y2; if (fabs(dy)>eps1){
double z2; ang =atan(-dx/dy);
} linetype, *linePtr; if (dy>0.0) return(ang);
if(ang>0.0) {ang = -pi+ang;}
/* find the distance between a point and a else { ang = pi+ang;}
line */ x,y
return(ang);
double
}else v1
dpl(x,y,x1,y1,x2,y2)
{ d
double x, y, x1, y1, x2, y2;
if (dx>0.0){
{
return( -pi/2.);
double ax, ay, bx, by, dl; v2
}else x1,y1 x2,y2
{
ax = x2 - x1;
return( pi/2.); v1 = (x–x1 ), ( y–y1)
ay = y2 - y1;
}
bx = x - x1; v2 = (x2–x1), (y2–y1)
}
by = y - y1; v v
} d = 1 2
dl = sqrt(ax*ax+ay*ay); v2
return(fabs(ax*by-ay*bx)/dl);
}
04/19/20 10 - 26
©T.C. Chang
UTILITY CODES
forward/backward transformation
/* tranform the object from x,y,z to x2,y2,z2
origin is x0,y0,z0, angle to the y axis is beta
dir = 0 transform
= 1 inverse transform
*/
void
tranf(dir,xi,yi,zi,beta,x1,y1,z1,x,y,z)
int dir;
double xi, yi, zi, beta, x1, y1, z1, *x, *y,
*z;
{
double dx,dy;
if(dir == 0){
dx = x1-xi;
dy = y1-yi;
*x = dx*cos(beta)+dy*sin(beta);
*y = -dx*sin(beta)+dy*cos(beta);
*z = z1;
} else if(dir == 1){
*x = xi+ x1*cos(beta)-y1*sin(beta);
*y = yi+ x1*sin(beta)+y1*cos(beta);
*z = z1;
}
}
04/19/20 10 - 27
©T.C. Chang
UTILITY CODES
forward/backward transformation
/* find the tangent lines from point to a circle
x1,y1,z1: Point x2,y2 r
x0,y0,r: circle
x = r *sqrt(1.0-(r/d)*(r/d));
1: left 0 right */ x0y0
if(lf_rgt == 1)x = -x;
void
glpntcir( x1,y1,z1,x0,y0,r, lf_rgt, ptr)
tranf(1,x1,y1,0.,beta,x,y,0.0,&
double x1,y1,z1,x0,y0,r; x2,&y2,&z);
linePtr ptr; ptr->x2= x2;
{ ptr->y2= y2;
double x,y,z,x2,y2; ptr->z2= z1; x1,y1
double d,d1, d2, beta;
}
d1 = (x1-x0)*(x1-x0);
d2 = (y1-y0)*(y1-y0);
d = sqrt(d1 + d2);
x0', y0'
if(d<= r) {
printf(" Point is inside the circle\n"); r
return;
}
/* transformation etc.*/
beta = yangl(x1,y1,x0,y0);
y = d - r*r/d;
x1' = 0,y1' = 0
04/19/20 10 - 28