extrapolation+normals looking nice. todo: get tangent before normal(normal could...
[engrid.git] / src / beziertriangle.h
blob7c339fbf501deba9b709846e1c13753a4257b2dc
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef BEZIERTRIANGLE_H
24 #define BEZIERTRIANGLE_H
26 #include "math/mathvector.h"
27 #include "math/linsolve.h"
28 #include "math/smallsquarematrix.h"
30 #include "egvtkobject.h"
31 #include "triangle.h"
33 #include <vtkUnstructuredGrid.h>
35 class BezierTriangle : public Triangle, public EgVtkObject {
36 public:
37 vec3_t m_X_200;
38 vec3_t m_X_020;
39 vec3_t m_X_002;
40 vec3_t m_X_011;
41 vec3_t m_X_101;
42 vec3_t m_X_110;
44 public:
45 BezierTriangle();
46 BezierTriangle(vec3_t X_200, vec3_t X_020, vec3_t X_002, vec3_t X_011, vec3_t X_101, vec3_t X_110);
48 void setControlPoints(vec3_t X_200, vec3_t X_020, vec3_t X_002, vec3_t X_011, vec3_t X_101, vec3_t X_110);
49 void getControlPoints(vec3_t& X_200, vec3_t& X_020, vec3_t& X_002, vec3_t& X_011, vec3_t& X_101, vec3_t& X_110);
50 vec2_t BaryCentric2xy(vec3_t barycoords);
51 vec3_t xy2BaryCentric(vec2_t xycoords);
52 vec3_t Bezier(vec2_t xycoords);
53 vec3_t Bezier(vec3_t barycoords);
54 vec3_t Projection(vec2_t xycoords);
55 vec3_t Projection(vec3_t barycoords);
56 void writeBezierSurface(QString filename, int N);
58 vec3_t quadraticBezierTriangle(double u, double v, double w);
59 vec3_t quadraticBezierTriangle(vec2_t M);
60 vec3_t quadraticBezierTriangle_g(vec3_t g_M);
62 vec3_t projectOnQuadraticBezierTriangle(vec3_t g_M, int output = 0);
64 vec3_t projectLocal2DOnQuadraticBezierTriangle(vec2_t t_M);
66 // stuff used for projections on the Bezier surface
67 private:
68 void setupFunctionVariables();
70 vec3_t m_l_X_200;
71 vec3_t m_l_X_020;
72 vec3_t m_l_X_002;
73 vec3_t m_l_X_011;
74 vec3_t m_l_X_101;
75 vec3_t m_l_X_110;
77 vec3_t m_coeff_x2;
78 vec3_t m_coeff_y2;
79 vec3_t m_coeff_xy;
80 vec3_t m_coeff_x;
81 vec3_t m_coeff_y;
82 public:
83 vec2_t fixedPointFunction(vec2_t t_inputPoint, double x, double y);
84 vec2_t fixedPointFunction(vec2_t t_inputPoint, vec2_t A);
85 mat2_t jacobiMatrix(double x, double y);
86 mat2_t jacobiMatrix_numeric(vec2_t t_inputPoint, double x, double y, double dx, double dy);
88 // mat3_t jacobiMatrix_no_projection(double x, double y);
89 vec3_t surfaceNormal(vec2_t t_M, int output);
90 double z_func(vec2_t t_M);
91 double z_func(double x, double y);
93 vec3_t projectOnBezierSide(vec3_t g_M, int side, double& Lmin, double& u);
94 bool insideBezierSurface(vec3_t g_M);
95 bool insideBezierSurface(vec2_t t_M);
96 bool insideBezierCurve(vec2_t t_M, int side, vec2_t& t_tangent, double tol = 1e-4);
98 vec3_t closestPointOnBezierCurves(vec3_t g_M, int& side, double& Lmin);
101 #endif