mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
Constructor for Trafo by rotation along an arbitrary axes, combine trafos
This commit is contained in:
parent
c0bb877ea5
commit
dab8c827fe
@ -163,7 +163,31 @@ ostream & operator<< (ostream & ost, Transformation3d & trans)
|
||||
return ost;
|
||||
}
|
||||
|
||||
template <>
|
||||
Transformation<3> :: Transformation (const Point<3> & c, const Vec<3> & axes, double angle)
|
||||
{
|
||||
Vec<3> vc(c);
|
||||
Transformation<3> tc(vc);
|
||||
Transformation<3> tcinv(-vc);
|
||||
Transformation<3> r, ht, ht2;
|
||||
|
||||
// r.SetAxisRotation (3, alpha);
|
||||
Vec<3> naxes = axes;
|
||||
naxes.Normalize();
|
||||
Vec<3> n1 = naxes.GetNormal();
|
||||
Vec<3> n2 = Cross(naxes, n1);
|
||||
r.v = Vec<3>(0,0,0);
|
||||
double co = cos(angle);
|
||||
double si = sin(angle);
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++)
|
||||
r.m(i,j) = naxes(i)*naxes(j) + co*(n1(i)*n1(j)+n2(i)*n2(j)) + si*( (n2(i)*n1(j)-n2(j)*n1(i)) );
|
||||
|
||||
ht.Combine (tc, r);
|
||||
Combine (ht, tcinv);
|
||||
}
|
||||
|
||||
|
||||
template <int D>
|
||||
Transformation<D> :: Transformation (const Point<D> * pp)
|
||||
{
|
||||
|
@ -102,6 +102,8 @@ public:
|
||||
m(i,i) = 1;
|
||||
}
|
||||
|
||||
Transformation (const Point<D> & c, const Vec<3> & axes, double angle);
|
||||
|
||||
// rotation with ...
|
||||
Transformation (const Point<D> & c, double alpha, double beta, double gamma)
|
||||
{
|
||||
|
@ -184,7 +184,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
([] (double x, double y) { return Vec<2>(x,y); }));
|
||||
|
||||
py::class_<Transformation<3>> (m, "Trafo")
|
||||
.def(py::init<Vec<3>>())
|
||||
.def(py::init<Vec<3>>(), "a translation")
|
||||
.def(py::init<Point<3>,Vec<3>,double>(), "a rotation given by point on axes, direction of axes, angle")
|
||||
.def("__mul__", [](Transformation<3> a, Transformation<3> b)->Transformation<3>
|
||||
{ Transformation<3> res; res.Combine(a,b); return res; })
|
||||
.def("__call__", [] (Transformation<3> trafo, Point<3> p) { return trafo(p); })
|
||||
;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user