Sun, 09/08/2013 - 06:03
Forums:
Hi,
How can I find the tangent of a 3d curve at a point?
Like this http://upload.wikimedia.org/wikipedia/commons/2/2d/Bezier_2_big.gif
GeomAPI_Interpolate seems promising
thanks
Hi,
How can I find the tangent of a 3d curve at a point?
Like this http://upload.wikimedia.org/wikipedia/commons/2/2d/Bezier_2_big.gif
GeomAPI_Interpolate seems promising
thanks
Mon, 09/09/2013 - 13:46
To have a tangent vector at a given parameter:
Geom_Curve::D1
To have the tangent unit vector:
GeomLProp_CLProps::Tangent
Regards.
Mauro
Tue, 09/10/2013 - 09:14
Hi Mauro,
How can I use this to draw a line?
thanks Daniel
Wed, 09/11/2013 - 19:44
To create an infinite tangent line, create a Geom_Line with the point and direction computed as said before.
If you need a finite one, create a Geom_TrimmedCurve from it.
Ciao.
Mauro
Sun, 09/22/2013 - 15:35
if you have a topoDS_Edge of a curve.
double parameter = 0.1;
gp_Pnt p1 = PointonCurve(curve,parameter);
gp_Vec v1 = getVectorTangentToCurveAtPoint(curve,parameter);
TopoDS_Shape l1 = Lineptdir(p1,v1,0,100)
use the following functions to get the point and vector at parameter.
They are extracts from the openshapefactory project.
https://code.google.com/p/openshapefactory/source/browse/SFMQTDLL/src/sr...
const gp_Vec& getVectorTangentToCurveAtPoint(TopoDS_Shape SupportEdge, Standard_Real uRatio)
{
if(SupportEdge.IsNull()) qDebug() << "supportedge null";
const TopoDS_Edge& aEdge = TopoDS::Edge (SupportEdge);
Standard_Real aFP, aLP, aP;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFP, aLP);
aP = aFP + (aLP - aFP) * uRatio;
gp_Vec& V1 = gp_Vec() ;
gp_Pnt p1;
aCurve->D1(aP,p1,V1);
return V1;
}
TopoDS_Edge Lineptdir(gp_Pnt origin, gp_Vec dir, double length1, double length2)
{
Handle(Geom_Curve) spinaxis = new Geom_Line (origin,dir);
spinaxis = new Geom_TrimmedCurve (spinaxis, length1, length2);
double fp = spinaxis->FirstParameter();
double ep = spinaxis->LastParameter();
TopoDS_Edge Result = BRepBuilderAPI_MakeEdge(spinaxis,fp,ep);
return Result;
}
const gp_Pnt& PointonCurve(TopoDS_Shape SupportEdge, Standard_Real uRatio)
{
gp_Pnt p1;
if (SupportEdge.IsNull())
{
return p1;
}
const TopoDS_Edge& aEdge = TopoDS::Edge (SupportEdge);
Standard_Real aFP, aLP, aP;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFP, aLP);
aP = aFP + (aLP - aFP) * uRatio;
p1 = aCurve->Value(aP);
return p1;
}
Sun, 01/22/2023 - 21:22
exactly what I was looking for. Thanks for sharing!