Основные функции (Basic Fubctions)
 
Синтез комплексного числа (Synthesis Of Complex Value)
 
Pascal

function MCompl;
var Z: Complex;
begin
if Abs(X)<Eps*Eps*Eps then X:=0;
if Abs(Y)<Eps*Eps*Eps then Y:=0;
Z.Re:=X;
Z.Im:=Y;
MCompl:=Z;
end; // MCompl

Max Script  
VHDL

function MCompl (X,Y: in TFloat) return TComplex is
variable Z: TComplex;
variable XX,YY: TFloat;
begin
XX:=X;
YY:=Y;
if Abs(X)<Eps*Eps*Eps then XX:=to_float(0,float_exponent_width,float_fraction_width); end if;
if Abs(Y)<Eps*Eps*Eps then YY:=to_float(0,float_exponent_width,float_fraction_width); end if;
Z.Re:=XX;
Z.Im:=YY;
return Z;
end MCompl;

JavaScript function MCompl(X,Y)
{
var Z = {Re:0, Im:0}
if (Math.abs(X)<Eps*Eps*Eps) X=0;
if (Math.abs(Y)<Eps*Eps*Eps) Y=0;
Z.Re=X;
Z.Im=Y;
return Z;
} // MCompl
 
Сложение комплексных чисел (Sum of Complex Values)
 
Pascal

function CompSum(X,Y: complex): complex;
var Z: complex;
begin
Z.Re:=X.Re+Y.Re;
Z.Im:=X.Im+Y.Im;
Result:=Z;
end; // CompSum

Max Script fn CompSum X Y = (Complex (X.Re+Y.Re) (X.Im+Y.Im))
VHDL

function CompSum(X,Y: in TComplex) return TComplex;

function CompSum(X,Y: in TComplex) return TComplex is
variable Z: TComplex;
begin
Z.Re:=X.Re+Y.Re;
Z.Im:=X.Im+Y.Im;
return Z;
end CompSum;

JavaScript function CompSum(X,Y)
{
var Z = {Re:0, Im:0}
Z.Re=X.Re+Y.Re;
Z.Im=X.Im+Y.Im;
return Z
} // CompSum
 
Разность комплексных чисел (Subtraction of Complex Values)
 
Pascal

function CompSub(X,Y: complex): complex;
var Z: complex;
begin
Z.Re:=X.Re-Y.Re;
Z.Im:=X.Im-Y.Im;
Result:=Z;
end; // CompSub

Max Script fn CompSub X Y = (Complex (X.Re-Y.Re) (X.Im-Y.Im))
VHDL

function CompSub(X,Y: in TComplex) return TComplex;

function CompSub(X,Y: in TComplex) return TComplex is
variable Z: TComplex;
begin
Z.Re:=X.Re-Y.Re;
Z.Im:=X.Im-Y.Im;
return Z;
end CompSub;

JavaScript function CompSub(X,Y)
{
var Z = {Re:0, Im:0}
Z.Re=X.Re-Y.Re;
Z.Im=X.Im-Y.Im;
return Z
} // CompSub
 
Произведение комплексных чисел (Multiplication of Complex Values)
 
Pascal

function CompMul(X,Y: complex): complex;
var Z: complex;
begin
Z.Re:=X.Re*Y.Re-X.Im*Y.Im;
Z.Im:=X.Re*Y.Im+Y.Re*X.Im;
Result:=Z;
end; // CompMul

Max Script fn CompMul X Y = (Complex (X.Re*Y.Re-X.Im*Y.Im) (X.Re*Y.Im+Y.Re*X.Im))
VHDL

function CompMul(X,Y: in TComplex) return TComplex is
variable Z: TComplex;
begin
Z.Re:=X.Re*Y.Re-X.Im*Y.Im;
Z.Im:=X.Re*Y.Im+Y.Re*X.Im;
return Z;
end CompMul;


JavaScript function CompMul(X,Y)
{
var Z = {Re:0, Im:0}
Z.Re=X.Re*Y.Re-X.Im*Y.Im;
Z.Im=X.Re*Y.Im+Y.Re*X.Im;
return Z;
} // CompMul
 
Деление комплексных чисел (Division of Complex Values)
 
Pascal

procedure CompDiv(X,Y: complex; var Z: complex; var Success: boolean);
begin
Success:=TRUE;
if Abs (Sqr(Y.Re)+Sqr(Y.Im))<Eps then
begin
Success:=FALSE;
end;
Z.Re:=(X.Re*Y.Re+X.Im*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
Z.Im:=(Y.Re*X.Im-X.Re*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
end; // CompDiv

Max Script fn CompDiv X Y &bum =
(
Success=TRUE
if ((Sqr Y.Re)+(Sqr Y.Im))<0.001 then Success=FALSE
local Q1=Double(X.Re)*Double(Y.Re)
local Q2=Double(X.Im)*Double(Y.Im)
local V1=Double(Q1+Q2)/Double(Sqr(Y.Re)+Sqr(Y.Im))
local V2=Double(Y.Re*X.Im-X.Re*Y.Im)/Double(Sqr(Y.Re)+Sqr(Y.Im))
bum = Complex V1 V2
return Success
)
VHDL

procedure CompDiv(X,Y: in TComplex; Z: out TComplex; Success: out boolean) is
variable FSuccess: boolean;
begin
FSuccess:=TRUE;
if
Abs(Sqr(Y.Re)+Sqr(Y.Im))<Eps then
FSuccess:=FALSE;
end if;

Z.Re:=(X.Re*Y.Re+X.Im*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
Z.Im:=(Y.Re*X.Im-X.Re*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
Success:=FSuccess;
end CompDiv;


JavaScript function CompDiv(X,Y)
{
var Z = {Re:0, Im:0}
Success=true;
if (Math.abs(Y.Re*Y.Re+Y.Im*Y.Im)<Eps) Success=false
Z.Re=(X.Re*Y.Re+X.Im*Y.Im)/(Y.Re*Y.Re+Y.Im*Y.Im);
Z.Im=(Y.Re*X.Im-X.Re*Y.Im)/(Y.Re*Y.Re+Y.Im*Y.Im);
return Z;
} // CompDiv
 
Квадрат комплексного числа (Compex Value Squared)
 
Pascal

function CompSqr(X: complex): complex;
begin
Result:=CompMul(X,X);
end; // CompSqr

Max Script fn CompSqr X = (CompMul X X)
VHDL


JavaScript function CompSqr(X)
{
return CompMul(X,X);
} // CompSqr
 
Корень квадратный комплексного числа (Square Root of Complex Value)
 
Pascal

function CompSqrt(X: complex): complex;
var A,B: real;
begin
A:=Sqrt((Sqrt(X.Re*X.Re+X.Im*X.Im)+X.Re)/2);
B:=Sign(X.Im)*Sqrt((Sqrt(X.Re*X.Re+X.Im*X.Im)-X.Re)/2);
Result:=MCompl(A,B);
end; // CompSqrt

Max Script

fn CompSqrt X =
(
local A1=X.Re*X.Re
local B1=X.Im*X.Im
local C1=Sqrt (A1+B1)
local D1=C1+X.Re
local AU=D1/2
AU=Sqrt AU
local D1=(C1-X.Re)/2
local BU=(Sign X.Im)*(Sqrt D1)
M=Complex AU BU
Return M
)

VHDL


JavaScript function CompSqrt(X)
{
var A,B;
A=Math.sqrt((Math.sqrt(X.Re*X.Re+X.Im*X.Im)+X.Re)/2);
B=Math.sign(X.Im)*Math.sqrt((Math.sqrt(X.Re*X.Re+X.Im*X.Im)-X.Re)/2);
return MCompl(A,B);
} // CompSqrt
 
Противоположное комплексное число (Opposite Complex VAlue)
 
Pascal

function CompNeg(X: complex): complex;
begin
Result:=MCompl(-X.Re,-X.Im);
end; // CompNeg

Max Script

fn CompNeg X = (
local M=Complex -(X.Re) -(X.Im)
return M
)

VHDL


JavaScript function CompNeg(X)
{
return MCompl(-X.Re,-X.Im);
} // CompNeg
 
Арксинус (Arc Sine)
 
Pascal

function ArcSin(X: extended): extended;
var A: extended;
begin
if(X>-1) and (X<1) then A:=ArcTan(X/Sqrt(1-Sqr(X)));
if(X>1-Sqr(Eps*Eps))then A:=PI/2;
if(X<-1+Sqr(Eps*EPS))then A:=PI/2;
ArcSin:=A;
end; // ArcSin

Max Script

fn ArcSin X =
(
if (X>-1.) and (X<1.) then local A=atan(X/Sqrt(1.-Sqr(X)))*Pi/180
if (X>=1.-Sqr(Eps*Eps)) then A=PI/2;
if (X<=-1.+Sqr(Eps*EPS)) then A=PI/2;
return A
)

VHDL


JavaScript

function ArcSin(X)
{
var A

if ((X>-1) && (X<1)) A=Math.atan(X/Math.sqrt(1-X*X));
if (X>1-Eps*Eps*Eps*Eps) A=Math.PI/2;
if (X<-1+Eps*Eps*Eps*Eps) A=-Math.PI/2;
return A;
} // ArcSin

 
Арккосинус (Arc Cosine)
 
Pascal

function ArcCos(X: extended): extended;
var A: real;
begin
ArcCos:=Pi/2-ArcSin(X);
end; // ArcCos

Max Script

fn ArcCos X =
(
local A=Pi/2-ArcSin X
return A
)

VHDL


JavaScript

function ArcCos(X)
{
return (Math.PI/2-ArcSin(X));
} // ArcCos

 
Угол (Angle)
 
Pascal

procedure Fi(Sa,Ca,Sb,Cb: real; var Df: real);

var Da1,Da2,Fi1,Fi2: real;
K: integer;
begin
Fi2:=ArcSin(Sb);
if (Sa>=0) and (Ca>=0) then Fi1:=ArcSin(Sa);
if (Sa>=0) and (Ca<0) then Fi1:=Pi-ArcSin(Sa);
if (Sa<0) and (Ca>=0) then Fi1:=ArcSin(Sa);
if (Sa<0) and (Ca<0) then Fi1:=-Pi-ArcSin(Sa);
if (Sb>=0) and (Cb>=0) then Fi2:=ArcSin(Sb);
if (Sb>=0) and (Cb<0) then Fi2:=Pi-ArcSin(Sb);
if (Sb<0) and (Cb>=0) then Fi2:=ArcSin(Sb);
if (Sb<0) and (Cb<0) then Fi2:=-Pi-ArcSin(Sb);
Df:=Fi2-Fi1;
end; // Fi


Max Script

fn Fi Sa Ca Sb Cb =
(
Fi2=ArcSin(Sb)
if (Sa>=0) and (Ca>=0) then Fi1=ArcSin(Sa)
if (Sa>=0) and (Ca<0) then Fi1=Pi-ArcSin(Sa)
if (Sa<0) and (Ca>=0) then Fi1=ArcSin(Sa)
if (Sa<0) and (Ca<0) then Fi1=-Pi-ArcSin(Sa)
if (Sb>=0) and (Cb>=0) then Fi2=ArcSin(Sb)
if (Sb>=0) and (Cb<0) then Fi2=Pi-ArcSin(Sb)
if (Sb<0) and (Cb>=0) then Fi2=ArcSin(Sb)
if (Sb<0) and (Cb<0) then Fi2=-Pi-ArcSin(Sb)
return Fi2-Fi1
)

VHDL


JavaScript

function Fi(Sa,Ca,Sb,Cb)
{
var Da1,Da2,Fi1,Fi2;
Fi2=ArcSin(Sb);
if ((Sa>=0) && (Ca>=0)) Fi1=ArcSin(Sa);
if ((Sa>=0) && (Ca<0)) Fi1=Math.PI-ArcSin(Sa);
if ((Sa<0) && (Ca>=0)) Fi1=ArcSin(Sa);
if ((Sa<0) && (Ca<0)) Fi1=-Math.PI-ArcSin(Sa);
if ((Sb>=0) && (Cb>=0)) Fi2=ArcSin(Sb);
if ((Sb>=0) && (Cb<0)) Fi2=Math.PI-ArcSin(Sb);
if ((Sb<0) && (Cb>=0)) Fi2=ArcSin(Sb);
if ((Sb<0) && (Cb<0)) Fi2=-Math.PI-ArcSin(Sb);
return Fi2-Fi1;
} // Fi

 
Синус-косинус (Sine-Cosine)
 
Pascal

procedure Sc(X1,Y1,X2,Y2: real; var S1,C1,Dl: real; var Prizn: boolean);
var Dx,Dy: real;
begin
Prizn:=FALSE;
Dx:=X2-X1; Dy:=Y2-Y1; Dl:=Sqrt(Sqr(Dx)+Sqr(Dy));
if Dl>0 then
begin
S1:=Dy/Dl;
C1:=Dx/Dl;
Prizn:=TRUE;
end;
end; // Sc


Max Script

fn Sc X1 Y1 X2 Y2 &S1 &C1 &Dl =
(

local Prizn=FALSE
local Dx=X2-X1
local Dy=Y2-Y1
local Dll=Sqrt(Dx*Dx+Dy*Dy)
if Dll>0 then
(
local S1=Float(Dy)/Float(Dll)
local C1=Float(Dx)/Float(Dll)
local Prizn=TRUE
)
return Prizn
)


VHDL


JavaScript

function SC(X1,Y1,X2,Y2)
{
var Dx,Dy,SCDP;
SCDP = {S:0, C:0, D:0, P:false}
SCDP.P=false;
Dx=X2-X1; Dy=Y2-Y1; SCDP.D=Math.sqrt(Dx*Dx+Dy*Dy);
if (SCDP.D>0)
{
SCDP.S=Dy/SCDP.D;
SCDP.C=Dx/SCDP.D;
SCDP.P=true;
}

return SCDP
} // Sc


 
Дискриминант матрицы 3x3 (Discriminant of 3x3 Matrix)
 
Pascal

function DiskrComp(P1,P2,P3,P4,P5,P6,P7,P8,P9: complex): complex;
var S1,S2,S3,S4,S5,S6,D1,D2: complex;
begin
// Diskr:=P1*P5*P9+P4*P8*P3+P7*P2*P6-P7*P5*P3-P1*P8*P6-P4*P2*P9;
S1:=CompMul(P1,CompMul(P5,P9));
S2:=CompMul(P4,CompMul(P8,P3));
S3:=CompMul(P7,CompMul(P2,P6));
S4:=CompMul(P7,CompMul(P5,P3));
S5:=CompMul(P1,CompMul(P8,P6));
S6:=CompMul(P4,CompMul(P2,P9));
D1:=CompSum(S1,CompSum(S2,S3));
D2:=CompSum(S4,CompSum(S5,S6));
Result:=CompSub(D1,D2);
end; // DiskrComp


Max Script

fn DiskrComp P1 P2 P3 P4 P5 P6 P7 P8 P9 =
(

local S1 = CompMul P1 (CompMul P5 P9)
local S2 = CompMul P4 (CompMul P8 P3)
local S3 = CompMul P7 (CompMul P2 P6)
local S4 = CompMul P7 (CompMul P5 P3)
local S5 = CompMul P1 (CompMul P8 P6)
local S6 = CompMul P4 (CompMul P2 P9)
local D1 = CompSum S1 (CompSum S2 S3)
local D2 = CompSum S4 (CompSum S5 S6)
CompSub D1 D2

)


VHDL


JavaScript

function DiskrComp(P1,P2,P3,P4,P5,P6,P7,P8,P9)
{
// Diskr:=P1*P5*P9+P4*P8*P3+P7*P2*P6-P7*P5*P3-P1*P8*P6-P4*P2*P9;
var S1 = {Re:0, Im:0}
var S2 = {Re:0, Im:0}
var S3 = {Re:0, Im:0}
var S4 = {Re:0, Im:0}
var S5 = {Re:0, Im:0}
var S6 = {Re:0, Im:0}
var D1 = {Re:0, Im:0}
var D2 = {Re:0, Im:0}

S1=CompMul(P1,CompMul(P5,P9));
S2=CompMul(P4,CompMul(P8,P3));
S3=CompMul(P7,CompMul(P2,P6));
S4=CompMul(P7,CompMul(P5,P3));
S5=CompMul(P1,CompMul(P8,P6));
S6=CompMul(P4,CompMul(P2,P9));
D1=CompSum(S1,CompSum(S2,S3));
D2=CompSum(S4,CompSum(S5,S6));
return CompSub(D1,D2);
} // DiskrComp


 
Пересечение прямых (Point of Lines Crossing)
 
Pascal

function LinLinComp(X1,Y1,X2,Y2,X3,Y3,X4,Y4: complex; var XX,YY,ZZ: complex): boolean;
var A1,B1,C1,A2,B2,C2: complex;
B,BB,BBB,Prizn: boolean;
V,XD: real;

label fin;

begin

Prizn:=FALSE;

if (X1.Im=0) and (X2.Im=0) and (X3.Im=0) and (X4.Im=0) and (Y1.Im=0) and (Y2.Im=0) and (Y3.Im=0) and (Y4.Im=0) then
BEGIN
V:=0.0001;
BB:=ProcA(X1.Re,Y1.Re,X2.Re,Y2.Re,X3.Re,Y3.Re,V,XD);
BBB:=ProcA(X1.Re,Y1.Re,X2.Re,Y2.Re,X4.Re,Y4.Re,V,XD);
if BB and BBB then
begin
B1:=CompSub(X2,X1);A1:=CompSub(Y1,Y2);
XX:=B1;
YY:=CompSub(MCompl(0,0),A1);
ZZ:=MCompl(0,0);
goto fin;
end;
END;

A1:=CompSub(Y1,Y2); B1:=CompSub(X2,X1);
A2:=CompSub(Y3,Y4); B2:=CompSub(X4,X3);
ZZ:=CompSub(CompMul(A1,B2),CompMul(B1,A2));

if (Abs(ZZ.Re)>1E-25) or (Abs(ZZ.Im)>1E-25) then
begin
C1:=CompSub(CompMul(X1,Y2),CompMul(Y1,X2));
C2:=CompSub(CompMul(X3,Y4),CompMul(Y3,X4));
CompDiv(CompSub(CompMul(B1,C2),CompMul(C1,B2)),ZZ,XX,B);
CompDiv(CompSub(CompMul(C1,A2),CompMul(A1,C2)),ZZ,YY,B);
ZZ:=MCompl(1,0);
Prizn:=TRUE
end;

if (Abs(ZZ.Re)<=1E-25) or (Abs(XX.Re)>1000000000) or (Abs(YY.Re)>1000000000) then
begin
XX:=B1;
YY:=CompSub(MCompl(0,0),A1);
ZZ:=MCompl(0,0);
end;

fin:
Result:=Prizn;

end; // LinLinComp


Max Script

function LinLinComp X1 Y1 X2 Y2 X3 Y3 X4 Y4 &XXA &YYA &ZZA =
(
Prizn=FALSE

if (X1.Im==0.) and (X2.Im==0.) and (X3.Im==0.) and (X4.Im==0.) and (Y1.Im==0.) and (Y2.Im==0.) and (Y3.Im==0.) and (Y4.Im==0.) then
(
V=0.0001;
BB=ProcA X1.Re Y1.Re X2.Re Y2.Re &X3.Re &Y3.Re V &XD
BBB=ProcA X1.Re Y1.Re X2.Re Y2.Re &X4.Re &Y4.Re V &XD
if BB and BBB then
(
B1=CompSub X2 X1
A1=CompSub Y1 Y2
XXA=B1
YYA=CompSub(Complex 0. 0.) A1
ZZA=Complex 0. 0.
return Prizn
Exit
)
)

A1=CompSub Y1 Y2
B1=CompSub X2 X1
A2=CompSub Y3 Y4
B2=CompSub X4 X3
ZZA=CompSub (CompMul A1 B2) (CompMul B1 A2)

if (Abs(ZZA.Re)>1E-25) or (Abs(ZZA.Im)>1E-25) then
(
C1=CompSub(CompMul X1 Y2) (CompMul Y1 X2)
C2=CompSub(CompMul X3 Y4) (CompMul Y3 X4)

U1=CompMul B1 C2
U2=CompMul C1 B2
U3=CompSub U1 U2
B=CompDiv U3 ZZA &XXA

U1=CompMul C1 A2
U2=CompMul A1 C2
U3=CompSub U1 U2
B=CompDiv U3 ZZA &YYA

-- B=CompDiv(CompSub(CompMul B1 C2) (CompMul(C1 B2))) ZZ &XX)
-- B=CompDiv(CompSub(CompMul C1 A2) (CompMul(A1 C2))) ZZ &YY)
ZZA=Complex 1. 0.
Prizn=TRUE
)

-- print ZZA
-- print XXA
-- print YYA

if (Abs(ZZA.Re)<=1E-25) or (Abs(XXA.Re)>1000000000.) or (Abs(YYA.Re)>1000000000.) then
(
XXA=B1
YYA=CompSub(Complex 0. 0.) A1
ZZA=Complex 0. 0.
)

return Prizn
)


VHDL


JavaScript

function LinLinComp(X1,Y1,X2,Y2,X3,Y3,X4,Y4)
{
var A1,B1,C1,A2,B2,C2;
var B,BB,BBB,Prizn;
var V,XD;
var R={XX:0,YY:0,ZZ:0,B:undefined}
Prizn=false;
if ((X1.Im==0) && (X2.Im==0) && (X3.Im==0) && (X4.Im==0) && (Y1.Im==0) && (Y2.Im==0) && (Y3.Im==0) && (Y4.Im==0))
{
V=0.0001;
BB=ProcA(X1.Re,Y1.Re,X2.Re,Y2.Re,X3.Re,Y3.Re,V);
BBB=ProcA(X1.Re,Y1.Re,X2.Re,Y2.Re,X4.Re,Y4.Re,V);
if (BB.B && BBB.B)
{
B1=CompSub(X2,X1);
A1=CompSub(Y1,Y2);
XX=B1;
YY=CompSub(MCompl(0,0),A1);
ZZ=MCompl(0,0);
R.XX=XX;
R.YY=YY;
R.ZZ=ZZ;
R.B=Prizn;
return R;
}
}

A1=CompSub(Y1,Y2); B1=CompSub(X2,X1);
A2=CompSub(Y3,Y4); B2=CompSub(X4,X3);
ZZ=CompSub(CompMul(A1,B2),CompMul(B1,A2));
if ((Math.abs(ZZ.Re)>1E-25) || (Math.abs(ZZ.Im)>1E-25))
{
C1=CompSub(CompMul(X1,Y2),CompMul(Y1,X2));
C2=CompSub(CompMul(X3,Y4),CompMul(Y3,X4));
Prizn=true
XX=CompDiv(CompSub(CompMul(B1,C2),CompMul(C1,B2)),ZZ);
if (Success==false) Prizn=false;
YY=CompDiv(CompSub(CompMul(C1,A2),CompMul(A1,C2)),ZZ);
if (Success==false) Prizn=false;
ZZ=MCompl(1,0);
}

if ((Math.abs(ZZ.Re)<=1E-25) || (Math.abs(XX.Re)>1000000000) || (Math.abs(YY.Re)>1000000000))
{
XX=B1;
YY=CompSub(MCompl(0,0),A1);
ZZ=MCompl(0,0);
}
R.XX=XX;
R.YY=YY;
R.ZZ=ZZ;
R.B=Prizn;
return R;
} // LinLinComp


 
ProcA
 
Pascal

function ProcA(X1,Y1,X2,Y2: real; var Xt,Yt: real; V: real; var XD: real): boolean;
var S,C,Dl,Dx,Xt1,Yt1,Df,X3,Y3,X4,Y4,A,B: real;
LDummy,Prizn: boolean;
begin
ProcA:=FALSE;
SC(X1,Y1,X2,Y2,S,C,Dl,LDummy);
Fi(0,1,S,C,Df);
Dx:=90*Pi/180+Df;
X3:=Xt+200*Cos(Dx);
Y3:=Yt+200*Sin(Dx);
X4:=Xt-200*Cos(Dx);
Y4:=Yt-200*Sin(Dx);
Prizn:=LinLin(X1,Y1,X2,Y2,X3,Y3,X4,Y4,Xt1,Yt1,C);
A:=Sqr(Xt-Xt1);B:=Sqr(Yt-Yt1);
XD:=Sqrt(A+B);

if XD< V then
begin
ProcA:=TRUE;
Xt:=Xt1;Yt:=Yt1;
end;
end; // ProcA


Max Script

fn ProcA X1 Y1 X2 Y2 &Xt &Yt V &XD =
(

Result=FALSE
Ldummy=SC X1 Y1 X2 Y2 &S &C &Dl
Df= Fi 0 1 S C
Dx=90.*Float(Pi/180.)+Df
X3=Xt+200.*Cos(Dx/Pi*180)
Y3=Yt+200.*Sin(Dx/Pi*180)
X4=Xt-200.*Cos(Dx/Pi*180)
Y4=Yt-200.*Sin(Dx/Pi*180)
Prizn=LinLin X1 Y1 X2 Y2 X3 Y3 X4 Y4 &Xt1 &Yt1 &C
A=Sqr(Xt-Xt1)
B=Sqr(Yt-Yt1)
XD=Sqrt(A+B)

if XD< V then
(
Result=TRUE
Xt=Xt1
Yt=Yt1
)
return Result
)


VHDL


JavaScript

function ProcA(X1,Y1,X2,Y2,Xt,Yt,V)
{
var S,C,Dl,Dx,Xt1,Yt1,Df,X3,Y3,X4,Y4,A,B;
var XTD = {Xt:undefined, Yt:undefined, D:undefined, B:undefined}

XTD.B=false;
SCDP=SC(X1,Y1,X2,Y2);
Df=Fi(0,1,SCDP.S,SCDP.C);
Dx=90*Math.PI/180+Df;
X3=Xt+200*Math.cos(Dx);
Y3=Yt+200*Math.sin(Dx);
X4=Xt-200*Math.cos(Dx);
Y4=Yt-200*Math.sin(Dx);
P=LinLin(X1,Y1,X2,Y2,X3,Y3,X4,Y4);
A=(Xt-Xt1)*(Xt-P.X);
B=(Yt-Yt1)*(Yt-P.Y);
XTD.D=Math.sqrt(A+B);

if (XTD.D<V)
{
XTD.Xt=P.X;
XTD.Yt=P.Y;
XTD.B=true;
}
return XTD;
} // ProcA


 
EExecC0
 
Pascal

function EExecC0(V: TObj; Var CST: TObj; Att: TAtt; Sg1: integer; OW: TNewList): boolean;
var A,B: complex;
T: boolean;
begin
Result:=FALSE;
if (V is TOChislU) then
begin
A:=TOChislU(V).C;
if Sg1=-1 then A.Re:=A.Re*Sg1;
Cst:=TOChislU.Create(A,tc_Variable,Att,OW,c_ord);
{Cst.Parents.Add(V);}
Cst.AssignParents([V]);

end else
if (V is TOChisl) then
begin
A:=TOChisl(V).C;
if Sg1=-1 then A.Re:=A.Re*Sg1;
Cst:=TOChisl.Create(A,tc_Variable,Att,OW,c_ord);
{Cst.Parents.Add(V);}
Cst.AssignParents([V]);

end else
begin
Cst:= TOEmpty.Create([V],OW,NIL);
end;
Result:=TRUE;
end; // EExecC0


Max Script

fn EExecC0 &M V Att Sg =
(
Success=false
M=TOChisl()
M.C=V.C
M.OB="C"

Success=true
Return Success
) -- EExecC0

VHDL


JavaScript

function EExecC0(M,V,Att,Sg)
{
var S
// alert("EExecC0")
S=false
// M=TOChisl()
M.C=V.C
// alert(M.C.Re)

S=true
return S
} // EExecC0


 
EExecP0
 
Pascal

function EExecP0( X,Y: TObj;
var Out_Prm: TObj;
var Att: TAtt;
Sg1,Sg2: integer;
OW: pointer): boolean;

var A,B: complex;
Kind: TKindPoint;

begin
Result:=FALSE;
Out_Prm:=NIL;

if ((X is TOChisl) or (X is TOPoint)) and ((Y is TOChisl) or (Y is TOPoint)) then
begin
if X is TOChisl then with TOChisl(X).C do Compl(A,Re*Sg1,Im*Sg1);
if Y is TOChisl then with TOChisl(Y).C do Compl(B,Re*Sg2,Im*Sg2);
if X is TOPoint then with TOPoint(X).X do Compl(A,Re*Sg1,Im*Sg1);
if Y is TOPoint then with TOPoint(Y).Y do Compl(B,Re*Sg2,Im*Sg2);

Kind:=tp_fixed;
if (X is TOChisl) and (Y is TOChisl) then if (TOChisl(X).Kind=tc_Constant) or (TOChisl(Y).Kind=tc_Constant) then Kind:=tp_halfFree;
if (X is TOChisl) and (Y is TOChisl) then if (TOChisl(X).Kind=tc_Constant) and (TOChisl(Y).Kind=tc_Constant) then Kind:=tp_free;

if (X is TOPoint) and (Y is TOChisl) then if (TOChisl(Y).Kind=tc_Constant) then Kind:=tp_halfFree;
if (X is TOChisl) and (Y is TOPoint) then if (TOChisl(X).Kind=tc_Constant) then Kind:=tp_halfFree;

Out_Prm:=TOPoint.Create(A,B,1,0,Kind,Att,OW);
end
else
begin
if Att.Chk=1 then Out_Prm:=TOEmpty.Create([X,Y],OW,NIL);
end;

Result:=TRUE;
end; // EExecP0



Max Script

fn EExecP0 &V X Y Att Sg1 Sg2 =
(
Success=FALSE
V=TOPoint()
V.X=X.C
V.Y=Y.C
V.W=1
V.OB="P"
Success=TRUE
Return Success

) --EExecP0

VHDL

entity ExecP0 is
port (X,Y: in TOConst; P: out TOPoint);
end entity;

architecture ExecP0 of ExecP0 is
begin
P.X<=X.C;
P.Y<=Y.C;
end;


JavaScript

function EExecP0(P,X,Y,Att,Sg1,Sg2)
{
// alert("EExecP0")
S=false
P.X=X.C;
P.Y=Y.C;
P.W=1;
P.OB="P";
P.Dir=znPlus;
S=true;
return S;
} // EExecP0

 
EExecP1
 
Pascal

function EExecP1(X,Y,Z: TObj; var Out_Prm: TObj; Att: TAtt; Sg1,Sg2,Sg3: integer; OW: pointer): boolean;
var A,B: complex;
Kind: TKindPoint;
Dx,Dy: complex;

begin
if (X is TOPoint) and ((Y is TOChisl) or (Y is TOPoint)) and ((Z is TOChisl) or (Z is TOPoint)) and TOPoint(X).IsSobstv then
begin
if Att.PT=8 then with X do
begin
Att.PT:=OAtt.PT;
Att.RColor:= OAtt.RColor;
Att.GColor:= OAtt.GColor;
Att.BColor:= OAtt.BColor;
end;
A.Re:=0; A.Im:=0;B.Re:=0; B.Im:=0;
if (Y is TOChisl) and (Z is TOChisl) then Compl(A,TOPoint(X).X.Re+TOChisl(Y).C.Re*Sg2,TOPoint(X).X.Im+TOChisl(Y).C.Im*Sg2);
if (Y is TOChisl) and (Z is TOChisl) then Compl(B,TOPoint(X).Y.Re+TOChisl(Z).C.Re*Sg3,TOPoint(X).Y.Im+TOChisl(Z).C.Im*Sg3);

if (Y is TOPoint) and (Z is TOChisl) then Compl(A,TOPoint(Y).X.Re*Sg2,TOPoint(Y).X.Im*Sg2);
if (Y is TOChisl) and (Z is TOPoint) then Compl(B,TOPoint(Z).Y.Re*Sg3,TOPoint(Z).Y.Im*Sg3);
if (Y is TOPoint) and (Z is TOPoint) then
begin
Compl(A,TOPoint(Y).X.Re*Sg2,TOPoint(Y).X.Im*Sg2);
Compl(B,TOPoint(Z).Y.Re*Sg3,TOPoint(Z).Y.Im*Sg3);
end;

Kind:=tp_fixed;
if (Y is TOChisl) and (Z is TOChisl) then if (TOChisl(Y).Kind=tc_Constant) or (TOCHisl(Z).Kind=tc_Constant) then Kind:=tp_halfFree;
if (Y is TOChisl) and (Z is TOChisl) then if (TOChisl(Y).Kind=tc_Constant) and (TOChisl(Z).Kind=tc_Constant) then Kind:=tp_free;

if (Y is TOPoint) and (Z is TOChisl) then if (TOChisl(Z).Kind=tc_Constant) then Kind:=tp_halfFree;
if (Y is TOChisl) and (Z is TOPoint) then if (TOChisl(Y).Kind=tc_Constant) then Kind:=tp_halfFree;

Out_Prm:=TOPoint.Create(A,B,1,0.5 ,Kind,Att,OW);
end else
if not (X is TOPoint) and (Y is TOChisl) and (Z is TOChisl) and TOPoint(X).IsSobstv then
begin
DX:=CompMul(TOChisl(Y).C,MCompl(Sg2,0));
DY:=CompMul(TOChisl(Z).C,MCompl(Sg3,0));
Out_Prm:=X.Shift(DX,DY,1,X.OAtt,OW);
end else
begin
if Att.Chk=1 then Out_Prm:=TOEmpty.Create([X,Y,Z],OW,NIL);
end;

Result:=TRUE;
end; // EExecP1


Max Script

fn EExecP1 &P P1 Dx Dy Att Sg1 Sg2 Sg3 =
(
Success=false
OB=TOPoint()
OB.X=CompSum P1.X Dx.C
OB.Y=CompSum P1.Y Dy.C
OB.W=P1.W
OB.OB="P"
P=OB
Success=true
Return Success
) -- EExecP1

VHDL

entity ExecP1 is
port (P: in TOPoint; X,Y: in TOConst; P1: out TOPoint);
end entity;

use work.spw_t.all;

architecture ExecP1 of ExecP1 is
begin
-- P1<=CompSumP(P,X,Y);
P1.X<=CompSum(P.X,X.C);
P1.Y<=CompSum(P.Y,Y.C);
end;


JavaScript

function EExecP1(P,P1,Dx,Dy,Att,Sg1,Sg2,Sg3)
{
// alert("EExecP1")
S=false;
P.X=CompSum(P1.X,Dx.C);
P.Y=CompSum(P1.Y,Dy.C);
P.W=P1.W;
P.OB="P";
P.Dir=znPlus;
S=true;
return S;
} // EExecP1

 
EExecO0
 
Pascal

function EExecO0(X,Y: TObj; var OOO: TObj; var Att: TAtt; Sg1,Sg2: Integer; OW: pointer): boolean;
var A,B,C,D,E,F: complex;
DL,S1,C1,Df: real;
O1,O2,O3,O4,OB1,OB2: TObj;
label lab1;


begin
OOO:=NIL;

if (X is TOMinus1) and (Y is TOMinus1) then
begin

EExecO0(TOMinus1(X).P,TOMinus1(Y).P,OB1,Att5,1,1,NIL);
EExecP2(TOMinus1(X).O,TOMinus1(Y).O,OB2,Att5,1,1,NIL);
OOO:=TOMinus1.Create(OB2,OB1,Att,OW);
OB1.Destroy;
OB2.Destroy;
Exit;
end;

if (X is TOMinus1) and (Y is TOPoint) then
begin
EExecO0(TOMinus1(X).P,Y,OB1,Att5,1,1,NIL);
EExecP2(TOMinus1(X).O,OB1,OB2,Att5,1,1,NIL);
OOO:=TOPoint.Create(TOPoint(OB2).X,TOPoint(OB2).Y,1,0.5,tp_fixed,Att,OW);
OB1.Destroy;
OB2.Destroy;
Exit;
end;

if (Y is TOMinus1) and (X is TOPoint) then
begin
EExecO0(TOMinus1(Y).P,X,OB1,Att5,1,1,NIL);
EExecP2(TOMinus1(Y).O,OB1,OB2,Att5,1,1,NIL);
OOO:=TOPoint.Create(TOPoint(OB2).X,TOPoint(OB2).Y,1,0.5,tp_fixed,Att,OW);
OB1.Destroy;
OB2.Destroy;
Exit;
end;

if (X is TOMinus1) and (Y is TOLine) then
begin
EExecP2(TOMinus1(X).O,Y,OB1,Att5,1,1,NIL);
EExecO0(TOMinus1(X).P,OB1,OOO,Att,1,1,NIL);
OB1.Destroy;
Exit;
end;

if (Y is TOMinus1) and (X is TOLine) then
begin
EExecP2(TOMinus1(Y).O,X,OB1,Att5,1,1,NIL);
EExecO0(TOMinus1(Y).P,OB1,OOO,Att,1,1,NIL);
OB1.Destroy;
Exit;
end;

if (X is TOMinus2) and (Y is TOLine) then
begin
EExecO0(TOMinus2(X).P1,TOMinus2(X).P2,OB1,Att5,1,1,NIL);
EExecP2(Y,OB1,OOO,Att,1,1,NIL);
OB1.Destroy;
Exit;
end;

if (Y is TOMinus2) and (X is TOLine) then
begin
EExecO0(TOMinus2(Y).P1,TOMinus2(Y).P2,OB1,Att,1,1,NIL);
EExecP2(X,OB1,OOO,Att5,1,1,NIL);
OB1.Destroy;
Exit;
end;

if (X is TOMinus2) and (Y is TOPoint) then
begin
EExecO0(TOMinus2(X).P1,TOMinus2(X).P2,OB1,Att5,1,1,NIL);
OOO:=TOMinus1.Create(OB1,Y,Att,OW);
OB1.Destroy;
Exit;
end;

if (Y is TOMinus2) and (X is TOPoint) then
begin
EExecO0(TOMinus2(Y).P1,TOMinus2(Y).P2,OB1,Att5,1,1,NIL);
OOO:=TOMinus1.Create(OB1,X,Att,OW);
OB1.Destroy;
Exit;
end;

if (X is TOMinus2) and (Y is TOMinus1) then
begin
EExecO0(TOMinus2(X).P1,TOMinus2(X).P2,OB1,Att5,1,1,NIL);
EExecP2(TOMinus1(Y).O,OB1,OB2,Att5,1,1,NIL);
OOO:=TOMinus2.Create(OB2,TOMinus1(Y).P,Att,OW);
OB1.Destroy;
OB2.Destroy;
Exit;
end;

if (Y is TOMinus2) and (X is TOMinus1) then
begin
EExecO0(TOMinus2(Y).P1,TOMinus2(Y).P2,OB1,Att5,1,1,NIL);
EExecP2(TOMinus1(X).O,OB1,OB2,Att5,1,1,NIL);
OOO:=TOMinus2.Create(OB2,TOMinus1(X).P,Att,OW);
OB1.Destroy;
OB2.Destroy;
Exit;
end;

if (X is TOPoint) and (Y is TOPoint){ and TOPoint(X).IsReal and TOPoint(Y).IsReal} then
begin
if (TOPoint(X).IsSobstv) and (TOPoint(Y).IsSobstv) then
begin
A:=TOPoint(X).X;
B:=TOPoint(X).Y;
C:=TOPoint(Y).X;
D:=TOPoint(Y).Y;
OOO:=TOLine.Create(A,B,1,C,D,1,brn_Limited,Sobstv,Att,OW,Ordinal);
Result:=TRUE;
AddInc(OOO,X);
AddInc(OOO,Y);
{DezargInc(OOO);}
end;
lab1:
if (TOPoint(X).W=1) and (TOPoint(Y).W=0) then
begin
A:=TOPoint(X).X;
B:=TOPoint(X).Y;
Dl:=Sqrt(Sqr(TOPoint(Y).X.re)+Sqr(TOPoint(Y).Y.re));
if Dl>0 then
begin
S1:=TOPoint(Y).Y.Re/Dl;
C1:=TOPoint(Y).X.Re/Dl;
end;
Fi(0,1,S1,C1,Df);
if Df<0 then Df:=2*Pi+Df;

(* C.Re:=TOPoint(X).X.Re+100*Cos(Df); C.Im:=0;
D.Re:=TOPoint(X).Y.Re+100*Sin(Df); D.Im:=0;
if (Abs(TOPoint(X).X.Im)>Eps) or (Abs(TOPoint(X).Y.Im)>Eps) then
OOO:=TOEmpty.Create([X,Y],OW,NIL) else
OOO:=TOLine.Create(A,B,1,C,D,1,brn_HalfLimited,Sobstv,Att,OW,Ordinal);
*)
C.Re:=TOPoint(X).X.Re+100*Cos(Df); C.Im:=TOPoint(X).X.Im;
D.Re:=TOPoint(X).Y.Re+100*Sin(Df); D.Im:=TOPoint(X).Y.Im;
// if (Abs(TOPoint(X).X.Im)>Eps) or (Abs(TOPoint(X).Y.Im)>Eps) then
// OOO:=TOEmpty.Create([X,Y],OW,NIL) else
OOO:=TOLine.Create(A,B,1,C,D,1,brn_HalfLimited,Sobstv,Att,OW,Ordinal);

AddInc(OOO,X);
AddInc(OOO,Y);
Result:=TRUE;
end;
if (TOPoint(Y).W=1) and (TOPoint(X).W=0) then
begin
A:=TOPoint(Y).X;
B:=TOPoint(Y).Y;
Dl:=Sqrt(Sqr(TOPoint(X).X.re)+Sqr(TOPoint(X).Y.re));
if Dl>0 then
begin
S1:=TOPoint(X).Y.Re/Dl;
C1:=TOPoint(X).X.Re/Dl;
end;
Fi(0,1,S1,C1,Df);
if Df<0 then Df:=2*Pi+Df;

(* C.Re:=TOPoint(Y).X.Re+100*Cos(Df); C.Im:=0;
D.Re:=TOPoint(Y).Y.Re+100*Sin(Df); D.Im:=0;
if (Abs(TOPoint(Y).X.Im)>Eps) or (Abs(TOPoint(Y).Y.Im)>Eps) then
OOO:=TOEmpty.Create([X,Y],OW,NIL) else
OOO:=TOLine.Create(A,B,1,C,D,1,brn_HalfLimited,Sobstv,Att,OW,Ordinal);
*)
C.Re:=TOPoint(Y).X.Re+100*Cos(Df); C.Im:=TOPoint(Y).X.Im;
D.Re:=TOPoint(Y).Y.Re+100*Sin(Df); D.Im:=TOPoint(Y).Y.Im;
// if (Abs(TOPoint(Y).X.Im)>Eps) or (Abs(TOPoint(Y).Y.Im)>Eps) then
// OOO:=TOEmpty.Create([X,Y],OW,NIL) else
OOO:=TOLine.Create(A,B,1,C,D,1,brn_HalfLimited,Sobstv,Att,OW,Ordinal);

 

AddInc(OOO,X);
AddInc(OOO,Y);
Result:=TRUE;
end;
if (TOPoint(X).W=0) and (TOPoint(Y).W=0) then
begin
A:=TOPoint(X).X;
A.Im:=0;
B:=TOPoint(X).Y;
B.Im:=0;
C:=TOPoint(Y).X;
C.Im:=0;
D:=TOPoint(Y).Y;
D.Im:=0;
OOO:=TOLine.Create(A,B,0,C,D,0,brn_Limited,NeSobstv,Att,OW,Ordinal);
AddInc(OOO,X);
AddInc(OOO,Y);
Result:=TRUE;
end;
end else
begin
if Att.Chk=1 then OOO:=TOEmpty.Create([X,Y],OW,NIL);
Result:=TRUE;
end;
end;


Max Script

fn EExecO0 &O P1 P2 Att Sg1 Sg2 =
(
Success= false
OB=TOLine()
OB.X1=P1.X
OB.Y1=P1.Y
OB.W1=P1.W
OB.X2=P2.X
OB.Y2=P2.Y
OB.W2=P2.W
OB.OB="O"
O=OB
Success=true
Return Success
) -- EExecO0

VHDL

entity ExecO0 is
port (P1,P2: in TOPoint; O: out TOLine);
end entity;

architecture ExecO0 of ExecO0 is
begin
O.X1<=P1.X;
O.Y1<=P1.Y;
O.X2<=P2.X;
O.Y2<=P2.Y;
end;


JavaScript

function EExecO0(O, P1, P2, Att, Sg1, Sg2)
{
// alert("EExecO0")
var S= false;
O.X1=P1.X;
O.Y1=P1.Y;
O.W1=P1.W;
O.X2=P2.X;
O.Y2=P2.Y;
O.W2=P2.W;
O.OB="O";
O.Dir=znPlus;
S=true;
return S;
} // EExecO0

 
EExecP2
 
Pascal

function EExecP2(X,Y: TObj; var PNT: TObj; var Att: TAtt; Sg1,Sg2: integer; OW: pointer): boolean;
var Def,Prizn: boolean;
XX,YY: complex;
ZZ: complex;
(*
procedure DezargInc(var P8: TObj);
var I_P8,I_O4,J_O4,J_P8,I_O8,J_O8,K1,K2,K3,L1,L2,L3,I_S,I_O3,J_O3,M1,M2,M3,N1,N2,N3 : integer;
T,O4,O8,A,B,A1,B1,O1,O1_Temp1,O1_Temp2,S,
O2,O2_Temp1,O2_Temp2,O2_Temp3,O3,C,C1,O6,O5,O6_Temp1,O6_Temp2,O5_Temp1,O5_Temp2,P9,P1,L: TObj;
PN : TNames;
function TripletP(var P1,P2,P3: TObj): boolean;
var OB1,OB2,OB3 : TObj;
I,J,K : integer;
begin
Result:=FALSE;
if (P1=P2) and (P1=P3) then Exit;
for I:=0 to P1.Incia.Count-1 do
begin
OB1:=P1.Incia[I];
for J:=0 to P2.Incia.Count-1 do
begin
OB2:=P2.Incia[J];
if OB1<>OB2 then Continue;
for K:=0 to P3.Incia.Count-1 do
begin
OB3:=P3.Incia[K];
if (OB1=OB2) and (OB1=OB3) then
begin
Result:=TRUE;
Exit;
end;
end;
end;
end;
end;

 

var S,C,Dl,Df: real;
LDummy: boolean;
A: complex;
X1,Y1: complex;
OB1,P1,Chisl90,P2,P3,CC,O1,XXX,YYY: TObj;
begin
Result:=TRUE;
PNT:=NIL;

if (X is TOPoint) and (Y is TOPoint) then
begin
PNT:=TOMinus2.Create(X,Y,Att,OW);
Exit;
end;

if (X is TOPoint) and (Y is TOLine) then
begin
PNT:=TOMinus1.Create(X,Y,Att,OW);
Exit;
end;

if (Y is TOPoint) and (X is TOLine) then
begin
PNT:=TOMinus1.Create(Y,X,Att,OW);
Exit;
end;

if (X is TOMinus1) and (Y is TOLine) then
begin
EExecP2(TOMinus1(X).O,Y,OB1,Att5,1,1,NIL);
PNT:=TOMinus2.Create(TOMinus1(X).P,OB1,Att,OW);
OB1.Destroy;
Exit;
end;

if (Y is TOMinus1) and (X is TOLine) then
begin
EExecP2(TOMinus1(Y).O,X,OB1,Att5,1,1,NIL);
PNT:=TOMinus2.Create(TOMinus1(Y).P,OB1,Att,OW);
OB1.Destroy;
Exit;
end;

if TOLine(X).Null and TOLine(Y).Null then
if Att.Chk=1 then
begin
PNT:=TOEmpty.Create([X,Y],OW,NIL);
Exit;
end;

if TOLine(X).Null then
begin
CalcPF(TOLine(X).X1,TOLine(X).Y1,Y,X1,Y1);
if (Abs(TOLine(X).X1.Re-X1.Re)<Eps) and ((Abs(TOLine(X).Y1.Re-Y1.Re)<Eps)) then
begin
PNT:=TOPoint.Create(TOLine(X).X1,TOLine(X).Y1,1,0.5 ,tp_fixed,Att,OW);
AddInc(X,PNT);
AddInc(Y,PNT);
end else
PNT:=TOEmpty.Create([X,Y],OW,NIL);

Exit;
end;

if TOLine(Y).Null then
begin
CalcPF(TOLine(Y).X1,TOLine(Y).Y1,X,X1,Y1);
if (Abs(TOLine(Y).X1.Re-X1.Re)<Eps) and ((Abs(TOLine(Y).Y1.Re-Y1.Re)<Eps)) then
begin
PNT:=TOPoint.Create(TOLine(Y).X1,TOLine(Y).Y1,1,0.5 ,tp_fixed,Att,OW);
AddInc(X,PNT);
AddInc(Y,PNT);
end else
PNT:=TOEmpty.Create([X,Y],OW,NIL);
Exit;
end;

 

if (X is TOLine) and (Y is TOLine) then
BEGIN
if X=Y then
begin
PNT:=X.CreateCopy(OW);
PNT.AssignParents([X,Y]);
Exit;
end;
XX:=Cmpn;YY:=Cmpn;

if (TOLine(X).IsSobstv) and (TOLine(Y).IsSobstv) then
{if (TOLine(X).IsReal) and (TOLine(Y).IsReal) then}
begin
{LinLin(TOLine(X).X1.Re,TOLine(X).Y1.Re,TOLine(X).X2.Re,TOline(X).Y2.Re,
TOLine(Y).X1.Re,TOLine(Y).Y1.Re,TOLine(Y).X2.Re,TOLine(Y).Y2.Re,Xx.Re,Yy.Re,ZZ.Re,Prizn);
}

Prizn:=LinLinComp(TOLine(X).X1,TOLine(X).Y1,TOLine(X).X2,TOline(X).Y2,
TOLine(Y).X1,TOLine(Y).Y1,TOLine(Y).X2,TOLine(Y).Y2,Xx,Yy,ZZ);

Def:=TRUE;

if ZZ.Re=1 then if X.PointBelongs(XX.Re,YY.Re) and Y.PointBelongs(XX.Re,YY.Re) then Def:=TRUE else Def:=FALSE;
if not Def then
begin
if Att.Chk=1 then PNT:=TOEmpty.Create([X,Y],OW,NIL);
Exit;
end;

if (ZZ.Re=1) then
begin
PNT:=TOPoint.Create(XX,YY,ZZ.Re,0.5 ,tp_fixed,Att,OW);
Result:=TRUE;
begin
AddInc(PNT,X);
AddInc(PNT,Y);
{DezargInc(Pnt);}
end;
Exit;
end;

if (ZZ.Re=0) and
((TOLine(X).draw_ASborned in [brn_unlimited,brn_halflimited]) or
(TOLine(X).OAtt.Lv in[drw_UnLimited, drw_Incidented, drw_ShortIncidented, drw_Plus,drw_Minus,drw_Opposite])) and
((TOLine(Y).draw_ASborned in [brn_unlimited,brn_halflimited]) or
(TOLine(Y).OAtt.Lv in[drw_UnLimited, drw_Incidented, drw_ShortIncidented, drw_Plus,drw_Minus,drw_Opposite])) then
begin
// проверяем, не являются ли параллельные линии совпавшими
(*
P1:=TOPoint.Create(MCompl(0,0),MCompl(0,0),1,0.5 ,tp_fixed,Att5,NIL);
Chisl90:=TOChisl.Create(MCompl(90,0),tc_Constant,NAtt,NIL,c_ord);

XXX:=TOLine.Create(TOLine(X).X1,TOLine(X).Y1,1,TOLine(X).X2,TOLine(X).Y2,1,brn_UnLimited,Sobstv,Att5,NIL,Ordinal);
YYY:=TOLine.Create(TOLine(Y).X1,TOLine(Y).Y1,1,TOLine(Y).X2,TOLine(Y).Y2,1,brn_UnLimited,Sobstv,Att5,NIL,Ordinal);
EExecO5(XXX,p1,Chisl90,o1,Att5,1,1,1,NIL);
EExecP2(XXX,O1,p2,Att5,1,1,NIL);
EExecP2(YYY,O1,p3,Att5,1,1,NIL);
EExecC2(P2,P3,CC,Att5,1,1,NIL);
if (Abs(TOChisl(CC).C.Re)<Eps) and (Abs(TOChisl(CC).C.Im)<Eps) then
begin
PNT:=X.CreateCopy(OW);
end else PNT:=TOPoint.Create(XX,YY,ZZ.Re,0.5 ,tp_fixed,Att,OW);

XXX.Destroy;
YYY.Destroy;
CC.Destroy;
P2.Destroy;
P3.Destroy;
O1.Destroy;
Chisl90.Destroy;
P1.Destroy;
*)
Result:=TRUE;

PNT:=TOPoint.Create(XX,YY,ZZ.Re,0.5 ,tp_fixed,Att,OW); //
AddInc(X,PNT);
AddInc(Y,PNT);
PNT.AssignParents([X,Y]);
Exit;
end else
begin
if Att.Chk=1 then PNT:=TOEmpty.Create([X,Y],OW,NIL);
Exit;
end;

end;

if (not TOLine(X).IsSobstv) and (TOLine(Y).IsSobstv) then
if (TOLine(X).IsReal) and (TOLine(Y).IsReal) then
begin
XX.Re:=TOLine(Y).X2.Re-TOLine(Y).X1.Re; XX.Im:=0;
YY.Re:=TOLine(Y).Y2.Re-TOLine(Y).Y1.Re; YY.Im:=0;
PNT:=TOPoint.Create(XX,YY,0,0,tp_fixed,Att,OW);
AddInc(X,PNT);
AddInc(Y,PNT);
Exit;
end;

if (not TOLine(Y).IsSobstv) and (TOLine(X).IsSobstv) then
if (TOLine(X).IsReal) and (TOLine(Y).IsReal) then
begin
XX.Re:=TOLine(X).X2.Re-TOLine(X).X1.Re; XX.Im:=0;
YY.Re:=TOLine(X).Y2.Re-TOLine(X).Y1.Re; YY.Im:=0;
PNT:=TOPoint.Create(XX,YY,0,0,tp_fixed,Att,OW);
AddInc(X,PNT);
AddInc(Y,PNT);
Exit;
end;

if (TOLine(X).Vid=NeSobstv) and (TOLine(Y).Vid=NeSobstv) then
begin
if Att.Chk=1 then PNT:=TOEmpty.Create([X,Y],OW,NIL);
Exit;
end;

if (TOLine(X).Vid=NeSobstv) and (TOLine(Y).Vid=Sobstv) then
begin
SC(TOLine(Y).X1.Re,TOLine(Y).Y1.Re,TOLine(Y).X2.Re,TOLine(Y).Y2.Re,S,C,Dl,Ldummy);
Fi(0,1,S,C,Df);
Df:=Df*180/(Pi);
Compl(A,Df,0);
PNT:=TOPoint.Create(MCompl(100*Cos(A.Re/180*Pi),0),MCompl(100*Sin(A.Re/180*Pi),0),0,0.5,tp_fixed,Att,OW);
PNT.AssignParents([X,Y]);
Exit;
end;

if (TOLine(Y).Vid=NeSobstv) and (TOLine(X).Vid=Sobstv) then
begin
SC(TOLine(X).X1.Re,TOLine(X).Y1.Re,TOLine(X).X2.Re,TOLine(X).Y2.Re,S,C,Dl,Ldummy);
Fi(0,1,S,C,Df);
Df:=Df*180/(Pi);
Compl(A,Df,0);
PNT:=TOPoint.Create(MCompl(100*Cos(A.Re/180*Pi),0),MCompl(100*Sin(A.Re/180*Pi),0),0,0.5,tp_fixed,Att,OW);
PNT.AssignParents([X,Y]);
Exit;
end;

END;

if Att.Chk=1 then PNT:=TOEmpty.Create([X,Y],OW,NIL);
end; // EExecP2



Max Script

fn EExecP2 &P O1 O2 Att Sg1 Sg2 =
(
Success=false
LinLinComp O1.X1 O1.Y1 O1.X2 O1.Y2 O2.X1 O2.Y1 O2.X2 O2.Y2 &XX &YY &ZZ
OB=TOPoint()
OB.X=XX
OB.Y=YY
OB.W=1
OB.OB="P"
P=OB
Success=true
Return Success
) -- EExecP2

VHDL

entity ExecP2 is
port (O1,O2: in TOLine; P: out TOPoint);
end entity;

architecture ExecP2 of ExecP2 is
signal B: boolean;
begin
LinLinComp(O1.X1,O1.Y1,O1.X2,O1.Y2,O2.X1,O2.Y2,O2.X2,O2.Y2,P.X,P.Y,P.Z,B);
end;


JavaScript

function EExecP2(P,O1,O2,Att,Sg1,Sg2)
{
// Q = new Object()
var S=false;
// alert("EExecP2");
Q=LinLinComp(O1.X1,O1.Y1,O1.X2,O1.Y2,O2.X1,O2.Y1,O2.X2,O2.Y2);
P.X=Q.XX;
P.Y=Q.YY;
P.W=Q.ZZ.Re;
P.OB="P";
P.Dir=znPlus;
S=true;
return S;
} // EExecP2