TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
+94
-138
@@ -13,7 +13,7 @@ public Bool Line(U8 *aux_data,
|
||||
{//Step through line segment calling callback.
|
||||
//Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1,_x,_y,_z,
|
||||
adx=AbsI64(dx),ady=AbsI64(dy),adz=AbsI64(dz);
|
||||
adx=AbsI64(dx),ady=AbsI64(dy),adz=AbsI64(dz);
|
||||
Bool first=TRUE;
|
||||
if (adx>=ady) {
|
||||
if (adx>=adz) {
|
||||
@@ -58,7 +58,7 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
x1<<=32; y1<<=32; z1<<=32;
|
||||
for (j=0;j<start;j++) {
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
x1+=dx; y1+=dy; z1+=dz;
|
||||
}
|
||||
if (step!=1 && step!=0) {
|
||||
dx*=step;
|
||||
@@ -68,7 +68,7 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
for (i=start;i<=d;i++) {
|
||||
if ((_x!=x1.i32[1] || _y!=y1.i32[1] || _z!=z1.i32[1] || first) &&
|
||||
!(*fp_plot)(aux_data,x1.i32[1],y1.i32[1],z1.i32[1]))
|
||||
!(*fp_plot)(aux_data,x1.i32[1],y1.i32[1],z1.i32[1]))
|
||||
return FALSE;
|
||||
first=FALSE;
|
||||
_x=x1.i32[1]; _y=y1.i32[1]; _z=z1.i32[1];
|
||||
@@ -80,82 +80,44 @@ public Bool Line(U8 *aux_data,
|
||||
}
|
||||
|
||||
#help_index "Graphics/Math/3D Transformation"
|
||||
public I64 *GrRotXNew(F64 è,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about X axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(è)*GR_SCALE,
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[5]=my_cos;
|
||||
r[10]=my_cos;
|
||||
r[9]=my_sin;
|
||||
r[6]=-my_sin;
|
||||
r[0]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrRotYNew(F64 ê,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about Y axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(ê)*GR_SCALE,
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[0]=my_cos;
|
||||
r[10]=my_cos;
|
||||
r[8]=-my_sin;
|
||||
r[2]=my_sin;
|
||||
r[5]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrRotZNew(F64 é,CTask *mem_task=NULL)
|
||||
{//MAlloc 4x4 matrix to rot about Z axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(é)*GR_SCALE,
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
I64 *r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
|
||||
r[0]=my_cos;
|
||||
r[5]=my_cos;
|
||||
r[4]=my_sin;
|
||||
r[1]=-my_sin;
|
||||
r[10]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrScaleNew(I64 *m1,F64 s,CTask *mem_task=NULL)
|
||||
{//MAlloc matrix that is scaled version of a 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 i,*r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
for (i=0;i<16;i++)
|
||||
r[i]=m1[i]*s;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrMulMat(I64 *m1,I64 *m2,CTask *mem_task=NULL)
|
||||
{//Multiply 4x4 matrices, return MAlloced matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
public I64 *Mat4x4MulMat4x4Equ(I64 *dst,I64 *m1,I64 *m2)
|
||||
{//Multiply 4x4 matrices and store in dst. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//Conceptually, the transform m1 is applied after m2
|
||||
I64 i,j,k,*r=CAlloc(sizeof(I64)*16,mem_task);
|
||||
F64 d;
|
||||
I64 i,j,k;
|
||||
F64 sum;
|
||||
for (i=0;i<4;i++) {
|
||||
for (j=0;j<4;j++) {
|
||||
for (k=0;k<4;k++) {
|
||||
d=m1[k+4*j];
|
||||
d*=m2[i+4*k]; //TODO! Possible overflow if norm > one.
|
||||
d/=GR_SCALE;
|
||||
r[i+4*j]+=d;
|
||||
}
|
||||
sum=0;
|
||||
for (k=0;k<4;k++)
|
||||
sum+=ToF64(m1[k+4*j])*ToF64(m2[i+4*k]);
|
||||
dst[i+4*j]=sum/GR_SCALE;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
return dst;
|
||||
}
|
||||
|
||||
public I64 *GrRotXEqu(I64 *m1,F64 è)
|
||||
public I64 *Mat4x4MulMat4x4New(I64 *m1,I64 *m2,CTask *mem_task=NULL)
|
||||
{//Multiply 4x4 matrices. Return MAlloced matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//Conceptually, the transform m1 is applied after m2
|
||||
return Mat4x4MulMat4x4Equ(MAlloc(sizeof(I64)*16,mem_task),m1,m2);
|
||||
}
|
||||
|
||||
public I64 *Mat4x4Equ(I64 *dst,I64 *src)
|
||||
{//Copy 4x4 Rot matrix.
|
||||
MemCpy(dst,src,sizeof(I64)*16);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL)
|
||||
{//Return MAlloced copy of 4x4 Rot matrix.
|
||||
return Mat4x4Equ(MAlloc(sizeof(I64)*16,mem_task),src);
|
||||
}
|
||||
|
||||
public I64 *Mat4x4RotX(I64 *m1,F64 è)
|
||||
{//Rot matrix about X axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(è)*GR_SCALE,
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(è)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[5]=my_cos;
|
||||
r[10]=my_cos;
|
||||
@@ -163,18 +125,14 @@ public I64 *GrRotXEqu(I64 *m1,F64
|
||||
r[6]=-my_sin;
|
||||
r[0]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrRotYEqu(I64 *m1,F64 ê)
|
||||
public I64 *Mat4x4RotY(I64 *m1,F64 ê)
|
||||
{//Rot matrix about Y axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(ê)*GR_SCALE,
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(ê)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
r[10]=my_cos;
|
||||
@@ -182,18 +140,14 @@ public I64 *GrRotYEqu(I64 *m1,F64
|
||||
r[2]=my_sin;
|
||||
r[5]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrRotZEqu(I64 *m1,F64 é)
|
||||
public I64 *Mat4x4RotZ(I64 *m1,F64 é)
|
||||
{//Rot matrix about Z axis. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
F64 my_cos=Cos(é)*GR_SCALE,
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
I64 r[16],*r2;
|
||||
my_sin=Sin(é)*GR_SCALE;
|
||||
I64 r[16],r2[16];
|
||||
MemSet(r,0,sizeof(r));
|
||||
r[0]=my_cos;
|
||||
r[5]=my_cos;
|
||||
@@ -201,14 +155,10 @@ public I64 *GrRotZEqu(I64 *m1,F64
|
||||
r[1]=-my_sin;
|
||||
r[10]=GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
r2=GrMulMat(r,m1);
|
||||
MemCpy(m1,r2,sizeof(I64)*16);
|
||||
Free(r2);
|
||||
return m1;
|
||||
return Mat4x4Equ(m1,Mat4x4MulMat4x4Equ(r2,r,m1));
|
||||
}
|
||||
|
||||
public I64 *GrScaleEqu(I64 *m1,F64 s)
|
||||
public I64 *Mat4x4Scale(I64 *m1,F64 s)
|
||||
{//Scale 4x4 matrix by value.
|
||||
I64 i;
|
||||
for (i=0;i<16;i++)
|
||||
@@ -216,7 +166,7 @@ public I64 *GrScaleEqu(I64 *m1,F64 s)
|
||||
return m1;
|
||||
}
|
||||
|
||||
public U0 GrScalePenWidth(CDC *dc=gr.dc)
|
||||
public U0 DCPenWidthScale(CDC *dc=gr.dc)
|
||||
{//Scale device context's pen width by norm of transformation.
|
||||
I64 d;
|
||||
if (dc->flags&DCF_TRANSFORMATION) {
|
||||
@@ -229,7 +179,7 @@ public U0 GrScalePenWidth(CDC *dc=gr.dc)
|
||||
}
|
||||
}
|
||||
|
||||
public I64 *GrSetTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationEqu(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
{//Set translation values in 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]=x<<32;
|
||||
r[1][3]=y<<32;
|
||||
@@ -238,7 +188,7 @@ public I64 *GrSetTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *GrAddTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationAdd(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
{//Add translation to 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]+=x<<32;
|
||||
r[1][3]+=y<<32;
|
||||
@@ -247,7 +197,7 @@ public I64 *GrAddTranslation(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
return r;
|
||||
}
|
||||
|
||||
public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
public Bool DCSymmetrySet(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
{//2D. Set device context's symmetry.
|
||||
F64 d;
|
||||
if (y1==y2 && x1==x2)
|
||||
@@ -256,8 +206,8 @@ public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
dc->sym.sny=x1-x2;
|
||||
dc->sym.snz=0;
|
||||
if (d=Sqrt(SqrI64(dc->sym.snx)+
|
||||
SqrI64(dc->sym.sny)+
|
||||
SqrI64(dc->sym.snz))) {
|
||||
SqrI64(dc->sym.sny)+
|
||||
SqrI64(dc->sym.snz))) {
|
||||
d=GR_SCALE/d;
|
||||
dc->sym.snx *= d;
|
||||
dc->sym.sny *= d;
|
||||
@@ -269,15 +219,16 @@ public Bool GrSetSymmetry(CDC *dc=gr.dc,I64 x1,I64 y1,I64 x2,I64 y2)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool GrSetSymmetry3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64 z2,I64 x3,I64 y3,I64 z3)
|
||||
public Bool DCSymmetry3Set(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,
|
||||
I64 x2,I64 y2,I64 z2,I64 x3,I64 y3,I64 z3)
|
||||
{//3D. Set device context's symmetry.
|
||||
F64 d,x,y,z,xx,yy,zz;
|
||||
I64 xx1,yy1,zz1,xx2,yy2,zz2,*r;
|
||||
xx1=x1-x2; yy1=y1-y2; zz1=z1-z2;
|
||||
xx2=x3-x2; yy2=y3-y2; zz2=z3-z2;
|
||||
if (!xx1 && !yy1 && !zz1 ||
|
||||
!xx2 && !yy2 && !zz2 ||
|
||||
xx1==xx2 && yy1==yy2 && zz1==zz2)
|
||||
!xx2 && !yy2 && !zz2 ||
|
||||
xx1==xx2 && yy1==yy2 && zz1==zz2)
|
||||
return FALSE;
|
||||
|
||||
x=yy1*zz2-zz1*yy2;
|
||||
@@ -304,12 +255,12 @@ public Bool GrSetSymmetry3(CDC *dc=gr.dc,I64 x1,I64 y1,I64 z1,I64 x2,I64 y2,I64
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public U0 GrReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
public U0 DCReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
{//Reflect 3D point about device context's symmetry. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 x=*_x<<32,y=*_y<<32,z=*_z<<32,
|
||||
xx=*_x-dc->sym.sx,yy=*_y-dc->sym.sy,zz=*_z-dc->sym.sz,
|
||||
d=(xx*dc->sym.snx+yy*dc->sym.sny+zz*dc->sym.snz)>>16,
|
||||
xn,yn,zn,xx2,yy2,zz2;
|
||||
xx=*_x-dc->sym.sx,yy=*_y-dc->sym.sy,zz=*_z-dc->sym.sz,
|
||||
d=(xx*dc->sym.snx+yy*dc->sym.sny+zz*dc->sym.snz)>>16,
|
||||
xn,yn,zn,xx2,yy2,zz2;
|
||||
xn=d*dc->sym.snx>>15;
|
||||
yn=d*dc->sym.sny>>15;
|
||||
zn=d*dc->sym.snz>>15;
|
||||
@@ -320,11 +271,11 @@ public U0 GrReflect(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
yy2=y+yn;
|
||||
zz2=z+zn;
|
||||
if (SqrI64(xx>>16 -dc->sym.sx<<16)+
|
||||
SqrI64(yy>>16 -dc->sym.sy<<16)+
|
||||
SqrI64(zz>>16 -dc->sym.sz<<16)<
|
||||
SqrI64(xx2>>16-dc->sym.sx<<16)+
|
||||
SqrI64(yy2>>16-dc->sym.sy<<16)+
|
||||
SqrI64(zz2>>16-dc->sym.sz<<16)) {
|
||||
SqrI64(yy>>16 -dc->sym.sy<<16)+
|
||||
SqrI64(zz>>16 -dc->sym.sz<<16)<
|
||||
SqrI64(xx2>>16-dc->sym.sx<<16)+
|
||||
SqrI64(yy2>>16-dc->sym.sy<<16)+
|
||||
SqrI64(zz2>>16-dc->sym.sz<<16)) {
|
||||
*_x=xx.i32[1]; *_y=yy.i32[1]; *_z=zz.i32[1];
|
||||
} else {
|
||||
*_x=xx2.i32[1]; *_y=yy2.i32[1]; *_z=zz2.i32[1];
|
||||
@@ -343,7 +294,7 @@ public Bool Circle(U8 *aux_data,
|
||||
F64 len_radians=2*ã)
|
||||
{//Step through circle arc calling callback.
|
||||
I64 i,j,len=Ceil(len_radians*radius),
|
||||
x,y,x1,y1,s1,s2,c;
|
||||
x,y,x1,y1,s1,s2,c;
|
||||
F64 t;
|
||||
if (radius<=0||!step) return TRUE;
|
||||
t=1.0/radius;
|
||||
@@ -387,7 +338,7 @@ public Bool Ellipse(U8 *aux_data,
|
||||
F64 len_radians=2*ã)
|
||||
{//Step through ellipse arc calling callback.
|
||||
I64 i,j,len,
|
||||
x,y,_x,_y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
|
||||
x,y,_x,_y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
|
||||
F64 t;
|
||||
Bool first=TRUE;
|
||||
if (x_radius<=0 || y_radius<=0 || !step)
|
||||
@@ -432,7 +383,7 @@ public Bool Ellipse(U8 *aux_data,
|
||||
|
||||
for (i=0;i<=len;i+=step) {
|
||||
if ((x>>SCALE2!=_x || y>>SCALE2!=_y || first) &&
|
||||
!(*fp_plot)(aux_data,cx+x>>SCALE2,cy+y>>SCALE2,cz))
|
||||
!(*fp_plot)(aux_data,cx+x>>SCALE2,cy+y>>SCALE2,cz))
|
||||
return FALSE;
|
||||
|
||||
_x=x>>SCALE2; _y=y>>SCALE2; first=FALSE;
|
||||
@@ -459,8 +410,8 @@ public Bool RegPoly(U8 *aux_data,
|
||||
F64 len_radians=2*ã)
|
||||
{//Step through regular polygon calling callback.
|
||||
I64 i,n,x,y,x1,y1,x2,y2,
|
||||
xx1,yy1,xx2,yy2,
|
||||
s1,s2,c, s12,s22,c2;
|
||||
xx1,yy1,xx2,yy2,
|
||||
s1,s2,c, s12,s22,c2;
|
||||
F64 angle_step;
|
||||
|
||||
if (sides<=0 || x_radius<=0 || y_radius<=0)
|
||||
@@ -512,7 +463,7 @@ public Bool RegPoly(U8 *aux_data,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#help_index "Graphics/Data Types;Math/Data Types"
|
||||
#help_index "Graphics/Data Types/D3I32;Math/Data Types/D3I32;Data Types/D3I32"
|
||||
public F64 D3I32Dist(CD3I32 *p1,CD3I32 *p2)
|
||||
{//Dist between p1 and p2.
|
||||
return Sqrt(SqrI64(p1->x-p2->x)+SqrI64(p1->y-p2->y)+SqrI64(p1->z-p2->z));
|
||||
@@ -534,16 +485,17 @@ public I64 D3I32NormSqr(CD3I32 *p)
|
||||
}
|
||||
|
||||
#help_index "Graphics/Math"
|
||||
public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
{//Go in 2nd order bezier calling callback.
|
||||
I64 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
|
||||
F64 x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[0]),
|
||||
s=0.5/d,t1,t2;
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[0]),
|
||||
s=0.5/d,t1,t2;
|
||||
xx=x0; yy=y0; zz=z0;
|
||||
if (first && !(*fp_plot)(aux_data,xx,yy,zz))
|
||||
return FALSE;
|
||||
@@ -573,23 +525,24 @@ public Bool Bezier2(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64
|
||||
}
|
||||
x=ctrl[2].x; y=ctrl[2].y; z=ctrl[2].z;
|
||||
if ((xx!=x || yy!=y || zz!=z) &&
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool first=TRUE)
|
||||
{//Go in 3rd order bezier calling callback.
|
||||
I64 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
|
||||
F64 x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z,
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[3])+
|
||||
D3I32Dist(&ctrl[3],&ctrl[0]),
|
||||
s=0.5/d,nt,t1,t2,t3;
|
||||
x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0,
|
||||
x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0,
|
||||
x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0,
|
||||
t,d=D3I32Dist(&ctrl[0],&ctrl[1])+
|
||||
D3I32Dist(&ctrl[1],&ctrl[2])+
|
||||
D3I32Dist(&ctrl[2],&ctrl[3])+
|
||||
D3I32Dist(&ctrl[3],&ctrl[0]),
|
||||
s=0.5/d,nt,t1,t2,t3;
|
||||
xx=x0; yy=y0; zz=z0;
|
||||
if (first && !(*fp_plot)(aux_data,xx,yy,zz))
|
||||
return FALSE;
|
||||
@@ -621,12 +574,13 @@ public Bool Bezier3(U8 *aux_data,CD3I32 *ctrl,Bool (*fp_plot)(U8 *aux,I64 x,I64
|
||||
}
|
||||
x=ctrl[3].x; y=ctrl[3].y; z=ctrl[3].z;
|
||||
if ((xx!=x || yy!=y || zz!=z) &&
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
!(*fp_plot)(aux_data,x,y,z))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
{//Go in 2nd order spline calling callback.
|
||||
I64 i,j;
|
||||
CD3I32 *c;
|
||||
@@ -692,7 +646,8 @@ public Bool BSpline2(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,
|
||||
Bool (*fp_plot)(U8 *aux,I64 x,I64 y,I64 z),Bool closed=FALSE)
|
||||
{//Go in 3rd order spline calling callback.
|
||||
I64 i,j;
|
||||
F64 x,y,z;
|
||||
@@ -786,10 +741,11 @@ public Bool BSpline3(U8 *aux_data,CD3I32 *ctrl,I64 cnt,Bool (*fp_plot)(U8 *aux,I
|
||||
#define CC_TOP 4
|
||||
#define CC_BOTTOM 8
|
||||
|
||||
public Bool ClipLine(I64 *_x1,I64 *_y1,I64 *_x2,I64 *_y2,I64 left,I64 top,I64 right,I64 bottom)
|
||||
public Bool ClipLine(I64 *_x1,I64 *_y1,I64 *_x2,I64 *_y2,
|
||||
I64 left,I64 top,I64 right,I64 bottom)
|
||||
{//Clip x1,y1 x2,y2 with left,top,right,bottom.
|
||||
I64 x,y,x1=*_x1,y1=*_y1,x2=*_x2,y2=*_y2,
|
||||
cc,cc1,cc2;
|
||||
cc,cc1,cc2;
|
||||
if (y1>bottom)
|
||||
cc1=CC_BOTTOM;
|
||||
else if (y1<top)
|
||||
|
||||
Reference in new issue
Block a user