-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpression.cc
More file actions
54 lines (50 loc) · 1.9 KB
/
Expression.cc
File metadata and controls
54 lines (50 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/******************************************************************************
(c) 2005-2016 Scientific Computation Research Center,
Rensselaer Polytechnic Institute. All rights reserved.
This work is open source software, licensed under the terms of the
BSD license as described in the LICENSE file in the top-level directory.
*******************************************************************************/
#include "BSpline.h"
#include <cmath>
#include <iostream>
using namespace Spline;
using std::vector;
void Spline::dummyAnalyticExpression(double phi, double dummy, double *xyz,
void *userdata) {}
void Spline::evalCoord(double para, double *xyz, void *userdata) {
Expression *R_p = ((Expression **)userdata)[0];
Expression *Z_p = ((Expression **)userdata)[1];
xyz[0] = R_p->eval(para);
xyz[1] = Z_p->eval(para);
// xyz[2]=0.0;
}
void Spline::evalNormalVector(Expression *xp, Expression *yp, double para,
double *normalvec) {
double dx = xp->evalFirstDeriv(para);
double dy = yp->evalFirstDeriv(para);
double arclen = sqrt(dx * dx + dy * dy);
// std::cout<<" dx "<<dx<<" dy "<<dy<<std::endl;
normalvec[0] = dy / arclen;
normalvec[1] = -1.0 * dx / arclen;
// normalvec[2]=0.0;
}
void Spline::evalCurvature(Expression *xp, Expression *yp, double para,
double *curv) {
double dx = xp->evalFirstDeriv(para);
double ddx = xp->evalSecondDeriv(para);
double dy = yp->evalFirstDeriv(para);
double ddy = yp->evalSecondDeriv(para);
// std::cout<<"dx dy "<<dx<<" "<<dy<<" ddx ddy "<<ddx<<" "<<ddy<<std::endl;
*curv =
(dx * ddy - dy * ddx) / ((dx * dx + dy * dy) * sqrt(dx * dx + dy * dy));
}
int Spline::calcuBinomial(int j, int i) {
if (j < i)
return 0;
int res = 1;
for (int ii = 0; ii < i; ii++)
res *= j - ii;
for (int ii = 0; ii < i; ii++)
res /= ii + 1;
return res;
}