# eryar

posts - 368, comments - 538, trackbacks - 0, articles - 0
##### Intersection between a 2d line and a conic in OpenCASCADE

Abstract. OpenCASCADE provides the algorithm to implementation of the analytical intersection between a 2d line and another conic curve. The conic is defined by its implicit quadaratic equation, so the intersection problem is become a polynomial roots finding problem. The paper focus on the 2d line intersection another conic algorithm implementation.

Key Words. 2d line intersection, conic

1.Introduction

Figure 1. 直线与圆锥曲线相交

2.Conic Implicit Equation

IntAna2d_Conic::IntAna2d_Conic (const gp_Lin2d& L) {
a = 0.0;
b = 0.0;
c = 0.0;
L.Coefficients(d,e,f);
f = 2*f;
}
IntAna2d_Conic::IntAna2d_Conic (const gp_Circ2d& C) {
C.Coefficients(a,b,c,d,e,f);
}
IntAna2d_Conic::IntAna2d_Conic (const gp_Elips2d& E) {
E.Coefficients(a,b,c,d,e,f);
}
IntAna2d_Conic::IntAna2d_Conic (const gp_Parab2d& P) {
P.Coefficients(a,b,c,d,e,f);
}
IntAna2d_Conic::IntAna2d_Conic (const gp_Hypr2d& H) {
H.Coefficients(a,b,c,d,e,f);
}

3.Intersection Implementation

void IntAna2d_AnaIntersection::Perform (const gp_Lin2d& L,
const IntAna2d_Conic& Conic)
{
Standard_Real A,B,C,D,E,F;
Standard_Real px0,px1,px2;
Standard_Real DR_A,DR_B,DR_C,X0,Y0;
Standard_Integer i;
Standard_Real tx,ty,S;

done = Standard_False;
nbp  = 0;
para = Standard_False;
iden = Standard_False;

Conic.Coefficients(A,B,C,D,E,F);
L.Coefficients(DR_A,DR_B,DR_C);
X0=L.Location().X();
Y0=L.Location().Y();

// Parametre: L

// X = Xo - L DR_B    et     Y = Yo + L DR_A

px0=F + X0*(D+D + A*X0 + 2.0*C*Y0) + Y0*(E+E + B*Y0);
px1=2.0*(E*DR_A - D*DR_B + X0*(C*DR_A - A*DR_B) + Y0*(B*DR_A - C*DR_B));
px2=DR_A*(B*DR_A - 2.0*C*DR_B) + A*(DR_B*DR_B);

MyDirectPolynomialRoots Sol(px2,px1,px0);

if(!Sol.IsDone()) {
done=Standard_False;
return;
}
else {
if(Sol.InfiniteRoots()) {
iden=Standard_True;
done=Standard_True;
return;
}
nbp=Sol.NbSolutions();
for(i=1;i<=nbp;i++) {
S=Sol.Value(i);
tx=X0 - S*DR_B;
ty=Y0 + S*DR_A;
lpnt[i-1].SetValue(tx,ty,S);
}
Traitement_Points_Confondus(nbp,lpnt);
}
done=Standard_True;
}

4.Conclusion

5.References

1. 人民教育出版社中学数学室. 数学第二册上. 人民教育出版社. 2000

2. 易大义, 沈云宝, 李有法. 计算方法. 浙江大学出版社. 2002

3. 李原, 张开富, 余剑峰. 计算机辅助几何设计技术及应用. 西北工业大学出版社. 2007

4. 丘维声. 解析几何. 北京大学出版社. 1996