1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032863: Cone surface returns wrong v derivative

* Fix error on computing V first derivative on a cone (take into account the slope of the conical generatrix).
* Add DRAW command 'sderivative' to compute certain derivative on a surface.
This commit is contained in:
azv 2022-03-24 22:21:06 +03:00 committed by smoskvin
parent 5ae6f08cc6
commit e4753a7d16
3 changed files with 84 additions and 0 deletions

View File

@ -176,6 +176,8 @@ gp_Vec ElSLib::ConeDN (const Standard_Real U,
}
else if(Nv == 1) {
Xdir.Multiply(sin(SAngle));
if (Nu == 0)
Xdir.Add(Pos.Direction().XYZ() * cos(SAngle));
return gp_Vec(Xdir);
}
return gp_Vec(0.0,0.0,0.0);

View File

@ -941,6 +941,36 @@ static Standard_Integer value (Draw_Interpretor& ,
return 0;
}
//=======================================================================
//function : derivative
//purpose :
//=======================================================================
static Standard_Integer derivative(Draw_Interpretor&,
Standard_Integer theArgc,
const char** theArgv)
{
if (theArgc != 9)
return 1;
Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theArgv[1]);
if (aSurf.IsNull())
return 1;
Standard_Real aU = Draw::Atof(theArgv[2]);
Standard_Real aV = Draw::Atof(theArgv[3]);
Standard_Integer aNu = Draw::Atoi(theArgv[4]);
Standard_Integer aNv = Draw::Atoi(theArgv[5]);
gp_Vec aDeriv = aSurf->DN(aU, aV, aNu, aNv);
Draw::Set(theArgv[6], aDeriv.X());
Draw::Set(theArgv[7], aDeriv.Y());
Draw::Set(theArgv[8], aDeriv.Z());
return 0;
}
//=======================================================================
//function : movepole
//purpose :
@ -1851,6 +1881,15 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands)
__FILE__,
value,g);
theCommands.Add("sderivative",
"sderivative surfname U V NU NV X Y Z\n"
" surfname : name of surface\n"
" U V : coordinates on probe point on surface\n"
" NU NV : order of derivative along U and V\n"
" X Y Z : output coordinates of the derivative",
__FILE__,
derivative, g);
theCommands.Add("parameters",
"parameters surf/curve X Y [Z] Tol U [V] : {X Y Z} point, {U V} output parameter(s)",
__FILE__,

View File

@ -0,0 +1,43 @@
puts "================================================="
puts "0032863: Cone surface returns wrong v derivative "
puts "================================================="
puts ""
cone c 0.2 2.0
set u 5.23290599890759
set v 5.06498283391571
# reference data
svalue c $u $v x y z dux duy duz dvx dvy dvz d2ux d2uy d2uz d2vx d2vy d2vz d2uvx d2uvy d2uvz
set dxRef [list [dval x] [dval dux] [dval dvx] [dval d2ux] [dval d2uvx] [dval d2vx]]
set dyRef [list [dval y] [dval duy] [dval dvy] [dval d2uy] [dval d2uvy] [dval d2vy]]
set dzRef [list [dval z] [dval duz] [dval dvz] [dval d2uz] [dval d2uvz] [dval d2vz]]
# compute derivatives till the second order
puts "======================================="
set tolerance 1.e-7
for {set order 1} {$order <= 2} {incr order} {
for {set nv 0} {$nv <= $order} {incr nv} {
set nu [expr $order - $nv]
set offset [expr $order * ($order + 1) / 2 + $nv]
set ref_dx [lindex $dxRef $offset]
set ref_dy [lindex $dyRef $offset]
set ref_dz [lindex $dzRef $offset]
sderivative c $u $v $nu $nv dx dy dz
set dx [dval dx]
set dy [dval dy]
set dz [dval dz]
puts ""
puts "Order of derivative: Nu = $nu, Nv = $nv"
puts "Expected ($ref_dx, $ref_dy, $ref_dz)"
puts "Actual ($dx, $dy, $dz)"
checkreal "dX " $dx $ref_dx $tolerance $tolerance
checkreal "dY " $dy $ref_dy $tolerance $tolerance
checkreal "dZ " $dz $ref_dz $tolerance $tolerance
puts "======================================="
}
}