Skip to content
Snippets Groups Projects
Commit 7812f223 authored by xuyangt3's avatar xuyangt3
Browse files

todo generate mesh from evaluation, reuse x and y

parent 82ab0791
No related branches found
No related tags found
1 merge request!1Temp eval bezier
#include "Project.h"
using Eigen::Matrix4d;
using Eigen::Vector4d;
using Eigen::MatrixXd;
using Eigen::Matrix;
Matrix4d subdivideWeights = (Matrix4d() <<
1., 0., 0., 0.,
0.5, 0.5, 0., 0.,
0.25, 0.5, 0.25, 0.,
0.125,0.375,0.375,0.125).finished();
Matrix4d basisWeights = (Matrix4d() <<
-1, 3,-3, 1,
3,-6, 3, 0,
-3, 3, 0, 0,
1, 0, 0, 0).finished();
Vec eval(double x, double y, Matrix<double,3,16> ctrlPts) {
Vector4d xCoeff = basisWeights*Vector4d(x*x*x, x*x, x, 1);
Vector4d yCoeff = basisWeights*Vector4d(y*y*y, y*y, y, 1);
MatrixXd faceCoeff = xCoeff.replicate<1,4>()*yCoeff.asDiagonal();
faceCoeff.resize(16,1);
// cout << faceCoeff;
return ctrlPts*faceCoeff;
}
int main(){
cout << subdivideWeights.reverse() << endl;
Matrix<double,3,16> points;
points.col(0) << 0,0,1;
points.col(1) << 1,0,50;
points.col(2) << 2,0,3;
points.col(3) << 3,0,0;
points.col(4) << 0,1,2;
points.col(5) << 1,1,1;
points.col(6) << 2,1,3;
points.col(7) << 3,1,1;
points.col(8) << 0,2,1;
points.col(9) << 1,2,4;
points.col(10) << 2,2,9;
points.col(11) << 3,2,16;
points.col(12) << 0,3,3;
points.col(13) << 1,3,0;
points.col(14) << 2,3,0;
points.col(15) << 3,3,30;
cout << eval(0.2,0.3,points);
cout << eval(0.3,0.2,points);
}
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