home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 March
/
Chip_1998-03_cd.bin
/
tema
/
MINICAD
/
MC7DEMO
/
MINICAD.1
/
SHAFTBRK.MPC
< prev
next >
Wrap
Text File
|
1997-04-30
|
2KB
|
87 lines
Procedure ShaftBreak;
{
⌐1997, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure creates a shaft break. Two points are selected across the diameter of the shaft to create the break.
}
LABEL 10,99;
CONST
ky0 = 0.052;
kx1 = 0.097; ky1 = 0.104;
kx2 = 0.292; ky2 = 0.208;
VAR
d,x1,y1,x2,y2,x3,y3,Theta : REAL;
x,y : ARRAY[1..8] OF REAL;
k : INTEGER;
Function xt(x,y,Theta : REAL) : REAL;
BEGIN
xt:=x*Cos(Theta)-y*Sin(Theta);
END;
Function yt(x,y,Theta : REAL) : REAL;
BEGIN
yt:=x*Sin(Theta)+y*Cos(Theta);
END;
{
Main program.
}
BEGIN
{
Get insertion points.
}
Message('Click the two endpoints. Double-click to end command.');
10:DSelectAll;
GetLine(x1,y1,x2,y2);
{
Determine shaft diameter and angle of break.
}
d:=Sqrt((y2-y1)^2 + (x2-x1)^2);
IF d = 0 THEN GOTO 99;
Theta:=ArcCos((x2-x1)/d);
IF y2 < y1 THEN Theta:=2*Pi-Theta;
{
Calculate the vertices of the polyline.
}
x[1]:=0; y[1]:=0;
x[2]:=0; y[2]:=ky0*d;
x[3]:=kx1*d; y[3]:=ky1*d;
x[4]:=kx2*d; y[4]:=ky2*d;
x[5]:=d/2; y[5]:=0;
x[6]:=(1-kx2)*d; y[6]:=-y[4];
x[7]:=d; y[7]:=0;
x[8]:=x[6]; y[8]:=y[4];
FOR k:=1 TO 8 DO
BEGIN
x3:=x[k]; y3:=y[k];
x[k]:=x1+xt(x3,y3,Theta);
y[k]:=y1+yt(x3,y3,Theta);
END;
{
Draw break.
}
Absolute;
MoveTo(x[1], y[1]);
OpenPoly;
BeginPoly;
LineTo(x[1],y[1]);
CurveTo(x[2],y[2]);
LineTo(x[3],y[3]);
CurveTo(x[4],y[4]);
LineTo(x[5],y[5]);
CurveTo(x[6],y[6]);
CurveThrough(x[7],y[7]);
CurveTo(x[8],y[8]);
LineTo(x[5],y[5]);
EndPoly;
Redraw;
GOTO 10;
99:ClrMessage;
END;
Run(ShaftBreak);