Skip to content
Snippets Groups Projects
Commit 90f4115f authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

oops

parent e707a28b
No related branches found
No related tags found
No related merge requests found
#include "gmshCurve.h"
#include "Geo.h"
#include "GeoInterpolation.h"
SVector3 gmshCurve::curvature (double t) const {
SVector3 dx = firstDer(t);
SVector3 dxx = secondDer(t);
double normdx = dx.norm();
double oneovernormdx = 1./normdx;
double oneovernormdx3 = oneovernormdx*oneovernormdx*oneovernormdx;
SVector3 c = (dxx * normdx - dx * (dot(dx,dxx) * oneovernormdx))*oneovernormdx3;
return c;
}
gmshCubicSpline::gmshCubicSpline (std::vector<SPoint3> & data)
{
c = Create_Curve ( 0 , MSH_SEGM_BSPLN , 3 , 0 , 0 , 0 , 0 , 0., 1.) ;
c->Control_Points = List_Create(data.size(), 1, sizeof(Vertex *));
for (unsigned int i=0;i<data.size(); i++){
Vertex *v = new Vertex (data[i].x(),data[i].y(),data[i].z(), 0.0);
List_Add (c->Control_Points, &v);
}
}
gmshCubicSpline::gmshCubicSpline (std::vector<SPoint2> & data)
{
c = Create_Curve ( 0 , MSH_SEGM_BSPLN , 3 , 0 , 0 , 0 , 0 , 0., 1.) ;
c->Control_Points = List_Create(data.size(), 1, sizeof(Vertex *));
for (unsigned int i=0;i<data.size(); i++){
Vertex *v = new Vertex (data[i].x(),data[i].y(),0.0, 0.0);
List_Add (c->Control_Points, &v);
}
}
SPoint3 gmshCubicSpline::point (double t) const
{
Vertex v = InterpolateCurve(c, t, 0);
return SPoint3 (v.Pos.X,v.Pos.Y,v.Pos.Z);
}
SVector3 gmshCubicSpline::firstDer (double t) const
{
Vertex v = InterpolateCurve(c, t, 1);
return SVector3 (v.Pos.X,v.Pos.Y,v.Pos.Z);
}
SVector3 gmshCubicSpline::secondDer (double t) const
{
Vertex v = InterpolateCurve(c, t, 2);
return SVector3 (v.Pos.X,v.Pos.Y,v.Pos.Z);
}
gmshCubicSpline::~gmshCubicSpline ()
{
for (int i=0;i< List_Nbr(c->Control_Points); i++){
Vertex *v;
List_Read(c->Control_Points, i, &v);
delete v;
}
List_Delete(c->Control_Points);
}
#ifndef _GMSH_CURVE_
#define _GMSH_CURVE_
#include <vector>
#include "SVector3.h"
#include "SPoint3.h"
#include "SPoint2.h"
class Curve;
class gmshCurve {
public :
virtual SPoint3 point (double t) const = 0;
virtual SVector3 firstDer (double t) const = 0;
virtual SVector3 secondDer (double t) const = 0;
SVector3 curvature (double t) const;
};
class gmshCubicSpline : public gmshCurve
{
Curve *c;
public:
gmshCubicSpline (std::vector<SPoint3> & data);
gmshCubicSpline (std::vector<SPoint2> & data);
~gmshCubicSpline();
virtual SPoint3 point (double t) const;
virtual SVector3 firstDer (double t) const;
virtual SVector3 secondDer (double t) const;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment