diff --git a/examples/convolve.cpp b/examples/convolve.cpp index bfd618b9..d14d0604 100644 --- a/examples/convolve.cpp +++ b/examples/convolve.cpp @@ -104,10 +104,10 @@ int main() auto rgvp = v.addVisualModel (rgv); // Demonstrate how to divide existing scale by 10: - float newGrad = hgvp->zScale.getParams(0)/10.0; + float newGrad = hgvp->zScale.get_params(0)/10.0; // Set this in a new zscale object: sm::scale zscale; - zscale.setParams (newGrad, 0); + zscale.set_params (newGrad, 0); // Use the un-owned pointer rgvp: rgvp->updateZScale (zscale); diff --git a/examples/cray_eye.cpp b/examples/cray_eye.cpp index 25d0cbcb..010af855 100644 --- a/examples/cray_eye.cpp +++ b/examples/cray_eye.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -73,7 +74,7 @@ int main (int argc, char** argv) auto ptype = mplot::compoundray::EyeVisual<>::projection_type::equirectangular; // mercator, equirectangular or cassini sm::vec<> centre = { 0, 0, 0 }; - sm::mat44 twod_tr; + sm::mat twod_tr; twod_tr.translate (sm::vec<>{0,0,-0.1}); eyevm->add_spherical_projection (ptype, twod_tr, centre, psrad); eyevm->pre_set_cone_length (4e-6f); diff --git a/examples/cubetrans.cpp b/examples/cubetrans.cpp index 17b99c84..c25c37b2 100644 --- a/examples/cubetrans.cpp +++ b/examples/cubetrans.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -56,12 +56,12 @@ int main() Eigen::Vector3f ed1_s (d1_s[0], d1_s[1], d1_s[2]); Eigen::Vector3f ed1_e (d1_e[0], d1_e[1], d1_e[2]); - // mat44 transformation - sm::mat44 m1t; - sm::mat44 m1tor; - sm::mat44 m1r; - sm::mat44 m1torb; - sm::mat44 m1t2; + // mat transformation + sm::mat m1t; + sm::mat m1tor; + sm::mat m1r; + sm::mat m1torb; + sm::mat m1t2; // sequence: m1t.translate (mv1); m1tor.translate (-(l1 + mv1)); @@ -69,7 +69,7 @@ int main() m1torb.translate (l1 + mv1); m1t2.translate (m1r * mv2); // Combine by multiplication: - sm::mat44 m1 = m1t2 * m1torb * m1r * m1tor * m1t; + sm::mat m1 = m1t2 * m1torb * m1r * m1tor * m1t; // Eigen transformation Eigen::Transform em1t; @@ -120,7 +120,7 @@ int main() * the transforms are applied. */ - // Apply mat44 + // Apply sm::mat sm::vec<> l2 = (m1 * l1).less_one_dim(); sm::vec<> d2_s = (m1 * d1_s).less_one_dim(); sm::vec<> d2_e = (m1 * d1_e).less_one_dim(); diff --git a/examples/cubetrans2.cpp b/examples/cubetrans2.cpp index 75e05adb..3a457dbb 100644 --- a/examples/cubetrans2.cpp +++ b/examples/cubetrans2.cpp @@ -1,9 +1,9 @@ -// Draw a cube with RhomboVisual and then make up vectors to transform with mat44s +// Draw a cube with RhomboVisual and then make up vectors to transform with sm::mat<>s #include #include -#include +#include #include #include #include @@ -46,12 +46,12 @@ int main() sm::vec<> d_l1_s = d_l1_s_e - d_l1_s_s; auto rotang1 = sm::mathconst::pi / 2; - // mat44 transformation - sm::mat44 m1t; - sm::mat44 m1tor; - sm::mat44 m1r; - sm::mat44 m1torb; - sm::mat44 m1t2; + // matrix transformation + sm::mat m1t; + sm::mat m1tor; + sm::mat m1r; + sm::mat m1torb; + sm::mat m1t2; // sequence: m1t.translate (mv1); m1tor.translate (-(l1_s + mv1)); @@ -59,9 +59,9 @@ int main() m1torb.translate (l1_s + mv1); m1t2.translate (m1r * mv2); // Combine by multiplication: - sm::mat44 m1 = m1t2 * m1torb * m1r * m1tor * m1t; + sm::mat m1 = m1t2 * m1torb * m1r * m1tor * m1t; - // Apply mat44 + // Apply matrix sm::vec<> l1_e = (m1 * l1_s).less_one_dim(); sm::vec<> d_l1_e_s = (m1 * d_l1_s_s).less_one_dim(); sm::vec<> d_l1_e_e = (m1 * d_l1_s_e).less_one_dim(); @@ -120,11 +120,11 @@ int main() std::cout << "cam frame 0 viewmatrix:\n" << ptrs[0]->getViewMatrix() << std::endl; - m1t.setToIdentity(); - m1tor.setToIdentity(); - m1r.setToIdentity(); - m1torb.setToIdentity(); - m1t2.setToIdentity(); + m1t.set_identity(); + m1tor.set_identity(); + m1r.set_identity(); + m1torb.set_identity(); + m1t2.set_identity(); m1t.translate (cshift1); diff --git a/examples/duochrome.cpp b/examples/duochrome.cpp index 9db1f8a8..bd40e745 100644 --- a/examples/duochrome.cpp +++ b/examples/duochrome.cpp @@ -25,7 +25,7 @@ int main() try { sm::vec offset = { 0.0, 0.0, 0.0 }; sm::scale scale; - scale.setParams (1.0, 0.0); + scale.set_params (1.0, 0.0); std::vector> points(slen*slen); std::vector> vecdata(slen*slen); diff --git a/examples/ellipse_pca.cpp b/examples/ellipse_pca.cpp index ba87d025..0cde95f8 100644 --- a/examples/ellipse_pca.cpp +++ b/examples/ellipse_pca.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include @@ -20,7 +20,7 @@ int main() sm::rand_normal rn1 (0.0f, 2.0f); sm::rand_normal rn2 (0.0f, 0.5f); sm::vvec> _x (n_samp, {0}); - sm::mat22 rotn; + sm::mat rotn; rotn.rotate (sm::mathconst::pi_over_8); for (unsigned int i = 0; i < n_samp; ++i) { _x[i] = rotn * sm::vec{ rn1.get(), rn2.get() }; diff --git a/examples/ellipsoid.cpp b/examples/ellipsoid.cpp index b90b2bfd..c651b9d3 100644 --- a/examples/ellipsoid.cpp +++ b/examples/ellipsoid.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -22,7 +23,7 @@ class PrimitiveVisual : public mplot::VisualModel void initializeVertices() { - sm::mat44 tr; + sm::mat tr; tr.rotate (sm::vec<>::uz(), sm::mathconst::pi_over_4); this->computeEllipsoid (sm::vec{0}, mplot::colour::royalblue, diff --git a/examples/grid_image.cpp b/examples/grid_image.cpp index 78600843..792252f4 100644 --- a/examples/grid_image.cpp +++ b/examples/grid_image.cpp @@ -45,7 +45,7 @@ int main() gv1->gridVisMode = mplot::GridVisMode::Triangles; gv1->setScalarData (&image_data_tlbr); gv1->cm.setType (mplot::ColourMapType::GreyscaleInv); // inverse greyscale is good for a monochrome image - gv1->zScale.setParams (0, 1); // As it's an image, we don't want relief, so set the zScale to have a zero gradient + gv1->zScale.set_params (0, 1); // As it's an image, we don't want relief, so set the zScale to have a zero gradient gv1->finalize(); v.addVisualModel (gv1); @@ -54,7 +54,7 @@ int main() gv2->gridVisMode = mplot::GridVisMode::Triangles; gv2->setScalarData (&image_data_bltr); gv2->cm.setType (mplot::ColourMapType::GreyscaleInv); - gv2->zScale.setParams (0, 1); + gv2->zScale.set_params (0, 1); gv2->finalize(); v.addVisualModel (gv2); @@ -63,7 +63,7 @@ int main() gv3->gridVisMode = mplot::GridVisMode::RectInterp; gv3->setScalarData (&image_data_tlbr); gv3->cm.setType (mplot::ColourMapType::GreyscaleInv); - gv3->zScale.setParams (0, 1); + gv3->zScale.set_params (0, 1); gv3->finalize(); v.addVisualModel (gv3); @@ -72,7 +72,7 @@ int main() gv4->gridVisMode = mplot::GridVisMode::RectInterp; gv4->setScalarData (&image_data_bltr); gv4->cm.setType (mplot::ColourMapType::GreyscaleInv); - gv4->zScale.setParams (0, 1); + gv4->zScale.set_params (0, 1); gv4->finalize(); v.addVisualModel (gv4); diff --git a/examples/hexgrid_image.cpp b/examples/hexgrid_image.cpp index 34877a10..5c03bed6 100644 --- a/examples/hexgrid_image.cpp +++ b/examples/hexgrid_image.cpp @@ -44,7 +44,7 @@ int main() // The inverse greyscale map is appropriate for a monochrome image hgv->cm.setType (mplot::ColourMapType::GreyscaleInv); // As it's an image, we don't want relief, so set the zScale to have a zero gradient - hgv->zScale.setParams (0, 1); + hgv->zScale.set_params (0, 1); hgv->finalize(); v.addVisualModel (hgv); diff --git a/examples/hexgrid_image_onsphere.cpp b/examples/hexgrid_image_onsphere.cpp index 49eaf4bf..63f31266 100644 --- a/examples/hexgrid_image_onsphere.cpp +++ b/examples/hexgrid_image_onsphere.cpp @@ -141,7 +141,7 @@ int main() hgv->setScalarData (&hex_image_data); // The only real difference is that this has no hgv->setDataCoords(&sphere_coords) call. hgv->cm.setType (mplot::ColourMapType::Inferno); - hgv->zScale.setParams (0, 1); // sets a z offset of 1 across the hexgrid + hgv->zScale.set_params (0, 1); // sets a z offset of 1 across the hexgrid hgv->addLabel (std::string("2D hexgrid"), sm::vec{1.2*r_sph, -1.2*r_sph, 1}, mplot::TextFeatures(0.05f)); diff --git a/examples/hexgrid_image_rect.cpp b/examples/hexgrid_image_rect.cpp index 880c3168..5995c941 100644 --- a/examples/hexgrid_image_rect.cpp +++ b/examples/hexgrid_image_rect.cpp @@ -46,7 +46,7 @@ int main() // The inverse greyscale map is appropriate for a monochrome image hgv->cm.setType (mplot::ColourMapType::GreyscaleInv); // As it's an image, we don't want relief, so set the zScale to have a zero gradient - hgv->zScale.setParams (0, 1); + hgv->zScale.set_params (0, 1); hgv->finalize(); v.addVisualModel (hgv); diff --git a/examples/model_crawler.cpp b/examples/model_crawler.cpp index 3f282591..0cc8bb45 100644 --- a/examples/model_crawler.cpp +++ b/examples/model_crawler.cpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include @@ -85,8 +87,8 @@ int main (int argc, char** argv) sm::vec mv_ca = sm::vec::uz() * move_step; // The viewmatrices have to be passed to mplot::NavMesh::compute_mesh_movement - sm::mat44 ca_view = cap->getViewMatrix(); - sm::mat44 sph_view = gvp->getViewMatrix(); + sm::mat ca_view = cap->getViewMatrix(); + sm::mat sph_view = gvp->getViewMatrix(); // Find the triangle that we're initially located above with // mplot::NavMesh::find_triangle_hit. This updates internal state in NavMesh. It could be diff --git a/examples/pi/convolve.cpp b/examples/pi/convolve.cpp index b14cfed9..f689dc27 100644 --- a/examples/pi/convolve.cpp +++ b/examples/pi/convolve.cpp @@ -106,10 +106,10 @@ int main() auto rgvp = v.addVisualModel (rgv); // Demonstrate how to divide existing scale by 10: - float newGrad = hgvp->zScale.getParams(0) / 10.0f; + float newGrad = hgvp->zScale.get_params(0) / 10.0f; // Set this in a new zscale object: sm::scale zscale; - zscale.setParams (newGrad, 0); + zscale.set_params (newGrad, 0); // Use the un-owned pointer rgvp: rgvp->updateZScale (zscale); diff --git a/examples/pointrows.cpp b/examples/pointrows.cpp index 37c9a945..bee025fc 100644 --- a/examples/pointrows.cpp +++ b/examples/pointrows.cpp @@ -32,7 +32,7 @@ int main() try { sm::vec offset = { 0.0, 0.0, 0.0 }; sm::scale scale; - scale.setParams (1.0, 0.0); + scale.set_params (1.0, 0.0); std::vector> points; std::vector data; // copy points[:][2] into data diff --git a/examples/quads.cpp b/examples/quads.cpp index c7a3e95a..3f909a50 100644 --- a/examples/quads.cpp +++ b/examples/quads.cpp @@ -28,7 +28,7 @@ int main() try { sm::vec offset = { 0.0, 0.0, 0.0 }; sm::scale scale1; - scale1.setParams (1.0, 0.0); + scale1.set_params (1.0, 0.0); std::vector> surfBoxes; diff --git a/examples/rosenbrock.cpp b/examples/rosenbrock.cpp index edfa5ce9..ac9f7e65 100644 --- a/examples/rosenbrock.cpp +++ b/examples/rosenbrock.cpp @@ -78,7 +78,7 @@ int main() hgv->hexVisMode = mplot::HexVisMode::Triangles; hgv->cm.setType (mplot::ColourMapType::Viridis); hgv->setScalarData (&banana_vals); - hgv->zScale.setParams (0.001f, 0.0f); + hgv->zScale.set_params (0.001f, 0.0f); hgv->colourScale.compute_scaling (0.01f, 5.0f); hgv->setAlpha (0.4f); hgv->finalize(); diff --git a/examples/rosenbrock_asa.cpp b/examples/rosenbrock_asa.cpp index 319dc087..4e1b5c66 100644 --- a/examples/rosenbrock_asa.cpp +++ b/examples/rosenbrock_asa.cpp @@ -59,7 +59,7 @@ int main() hgv->hexVisMode = mplot::HexVisMode::Triangles; hgv->cm.setType (mplot::ColourMapType::Viridis); hgv->setScalarData (&banana_vals); - hgv->zScale.setParams (0.001f, 0.0f); + hgv->zScale.set_params (0.001f, 0.0f); hgv->colourScale.compute_scaling (0.01f, 5.0f); hgv->setAlpha (0.4f); hgv->finalize(); diff --git a/examples/rotating_models.cpp b/examples/rotating_models.cpp index 49c20bb0..e2e05a82 100644 --- a/examples/rotating_models.cpp +++ b/examples/rotating_models.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/examples/scatter.cpp b/examples/scatter.cpp index 3ed6101e..b32dcd9d 100644 --- a/examples/scatter.cpp +++ b/examples/scatter.cpp @@ -29,7 +29,7 @@ int main() try { sm::vec offset = { 0.0, 0.0, 0.0 }; sm::scale scale1; - scale1.setParams (1.0, 0.0); + scale1.set_params (1.0, 0.0); // Note use of sm::vvecs here, which can be passed into // VisualDataModel::setDataCoords(std::vector>* _coords) diff --git a/examples/scatter_geodesic.cpp b/examples/scatter_geodesic.cpp index abc9051f..70a69eeb 100644 --- a/examples/scatter_geodesic.cpp +++ b/examples/scatter_geodesic.cpp @@ -64,7 +64,7 @@ int main() try { sm::vec offset = { 0.0f, 0.0f, 0.0f }; sm::scale scale; - scale.setParams (1.0f, 0.0f); + scale.set_params (1.0f, 0.0f); sm::vvec data(geo.poly.vertices.size(), 0.06f); sm::vvec data2(geo.poly.faces.size(), 0.95f); diff --git a/examples/scatter_hex_mercator.cpp b/examples/scatter_hex_mercator.cpp index aeed2e46..8431323e 100644 --- a/examples/scatter_hex_mercator.cpp +++ b/examples/scatter_hex_mercator.cpp @@ -24,7 +24,7 @@ int main() sm::vec offset = { 0.0f, 0.0f, 0.0f }; sm::scale scale; - scale.setParams (1.0f, 0.0f); + scale.set_params (1.0f, 0.0f); // Have a Sphere of radius 1 constexpr float r_sph = 1.0f; diff --git a/examples/scatter_ico.cpp b/examples/scatter_ico.cpp index 828383de..7a3015b5 100644 --- a/examples/scatter_ico.cpp +++ b/examples/scatter_ico.cpp @@ -37,7 +37,7 @@ int main() try { sm::vec offset = { 0.0, 0.0, 0.0 }; sm::scale scale; - scale.setParams (1.0, 0.0); + scale.set_params (1.0, 0.0); sm::vvec data(12, 0.06f); sm::vvec data2(20, 0.95f); diff --git a/examples/showcase.cpp b/examples/showcase.cpp index 647d9324..d54a41ce 100644 --- a/examples/showcase.cpp +++ b/examples/showcase.cpp @@ -186,7 +186,7 @@ int main() gv3->interpolate_colour_sides (true); gv3->setScalarData (&image_data); gv3->cm.setType (mplot::ColourMapType::Plasma); - gv3->zScale.setParams (0.1, 0); // Reduce height in 'z' + gv3->zScale.set_params (0.1, 0); // Reduce height in 'z' gv3->addLabel ("mplot::GridVisual (columns)", sm::vec({0,-0.1,0}), mplot::TextFeatures(0.05)); gv3->finalize(); v.addVisualModel (gv3); diff --git a/examples/vectorvis.cpp b/examples/vectorvis.cpp index 7c5f766c..4e516192 100644 --- a/examples/vectorvis.cpp +++ b/examples/vectorvis.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ int main() vvm->thevec = {1,1,1}; vvm->fixed_colour = true; vvm->single_colour = mplot::colour::royalblue; - vvm->addLabel ("Rotn by mat44", {-0.8, -0.5, 0}, mplot::TextFeatures(0.1f)); + vvm->addLabel ("Rotn by 4x4 mat", {-0.8, -0.5, 0}, mplot::TextFeatures(0.1f)); vvm->finalize(); auto ptr2 = v.addVisualModel (vvm); @@ -49,7 +49,7 @@ int main() // Set up a rotation about the z axis sm::quaternion qr (axis, angle_per_frame); - sm::mat44 tf; + sm::mat tf; tf.rotate (axis, angle_per_frame); while (!v.readyToFinish()) { diff --git a/maths b/maths index 90f1c5f6..db4ab32e 160000 --- a/maths +++ b/maths @@ -1 +1 @@ -Subproject commit 90f1c5f6a85af3099b8c5521e2a171525e29a789 +Subproject commit db4ab32e0bc8b98fbd58ac4eb6289dae4cbf1247 diff --git a/mplot/CartGridVisual.h b/mplot/CartGridVisual.h index bab729e9..f9344fc9 100644 --- a/mplot/CartGridVisual.h +++ b/mplot/CartGridVisual.h @@ -56,7 +56,7 @@ namespace mplot sm::vec pixel_offset = { _cg->getd()/2.0f, _cg->getv()/2.0f, 0.0f }; this->viewmatrix.translate (_offset + pixel_offset); // Defaults for z and colourScale - this->zScale.setParams (1, 0); + this->zScale.set_params (1, 0); this->colourScale.do_autoscale = true; this->colourScale2.do_autoscale = true; this->colourScale3.do_autoscale = true; diff --git a/mplot/GraphVisual.h b/mplot/GraphVisual.h index 899541c7..19bb6519 100644 --- a/mplot/GraphVisual.h +++ b/mplot/GraphVisual.h @@ -427,13 +427,13 @@ namespace mplot auto _dx = g.get_dx(); if (ds.axisside == mplot::axisside::left) { this->ord1_scale.transform (g_v_y, sd); - this->quiver_grid_spacing[1] = _dx[1] * this->ord1_scale.getParams(0); + this->quiver_grid_spacing[1] = _dx[1] * this->ord1_scale.get_params(0); } else { this->ord2_scale.transform (g_v_y, sd); - this->quiver_grid_spacing[1] = _dx[1] * this->ord2_scale.getParams(0); + this->quiver_grid_spacing[1] = _dx[1] * this->ord2_scale.get_params(0); } this->abscissa_scale.transform (g_v_x, ad); - this->quiver_grid_spacing[0] = _dx[0] * this->abscissa_scale.getParams(0); + this->quiver_grid_spacing[0] = _dx[0] * this->abscissa_scale.get_params(0); // Now sd and ad can be used to construct dataCoords x/y. They are used to // set the position of each datum into dataCoords diff --git a/mplot/GridVisual.h b/mplot/GridVisual.h index 7e4faedb..72ff5fae 100644 --- a/mplot/GridVisual.h +++ b/mplot/GridVisual.h @@ -68,7 +68,7 @@ namespace mplot sm::vec pixel_offset = _grid->get_dx().plus_one_dim (0.0f); this->viewmatrix.translate (_offset + pixel_offset); // Defaults for z and colourScale - this->zScale.setParams (1, 0); + this->zScale.set_params (1, 0); this->colourScale.do_autoscale = true; this->colourScale2.do_autoscale = true; this->colourScale3.do_autoscale = true; diff --git a/mplot/HexGridVisual.h b/mplot/HexGridVisual.h index b4b77d84..c2e001ee 100644 --- a/mplot/HexGridVisual.h +++ b/mplot/HexGridVisual.h @@ -67,7 +67,7 @@ namespace mplot HexGridVisual(const sm::hexgrid* _hg, const sm::vec _offset) { this->viewmatrix.translate (_offset); - this->zScale.setParams (1, 0); + this->zScale.set_params (1, 0); this->colourScale.do_autoscale = true; this->colourScale2.do_autoscale = true; this->colourScale3.do_autoscale = true; diff --git a/mplot/NavMesh.h b/mplot/NavMesh.h index 8ee81e9e..ceea4d6c 100644 --- a/mplot/NavMesh.h +++ b/mplot/NavMesh.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace mplot @@ -129,7 +129,7 @@ namespace mplot * \param scene_coord Supplied coordinate in scene frame of referencea * \param viewmatrix The viewmatrix of the model which converts model frame coordinates to the scene frame */ - uint32_t find_vertex_nearest (const sm::vec& scene_coord, const sm::mat44& viewmatrix) const + uint32_t find_vertex_nearest (const sm::vec& scene_coord, const sm::mat& viewmatrix) const { uint32_t i = std::numeric_limits::max(); // Brute force it. (But we have a mesh; can this guarantee a faster search? I don't think so) @@ -156,7 +156,7 @@ namespace mplot } // Return the three vertices for the triangle specified as three indices into NavMesh::vertex transformed by transform - sm::vec, 3> triangle_vertices (const std::array& tri_indices, const sm::mat44& transform) const + sm::vec, 3> triangle_vertices (const std::array& tri_indices, const sm::mat& transform) const { sm::vec, 3> trivert; if (tri_indices[0] < this->vertex.size()) { trivert[0] = (transform * this->vertex[tri_indices[0]]).less_one_dim(); } @@ -572,8 +572,8 @@ namespace mplot } // Create a matrix to convert from mdl frame movements to the triangle frame of ref. - sm::mat44 from_triangle_frame = sm::mat44::frombasis (u_x, u_y, u_z); - sm::mat44 to_triangle_frame = from_triangle_frame.inverse(); + sm::mat from_triangle_frame = sm::mat::frombasis (u_x, u_y, u_z); + sm::mat to_triangle_frame = from_triangle_frame.inverse(); // Use Edge as our 'y' and the orthogonal as our 'x', then express mv_inplane in terms // of these two unit vectors. We also have our 'z' which is the triangle normal. @@ -848,7 +848,7 @@ namespace mplot * triangle we hit; and the indices of the triangle we hit. */ std::tuple, sm::vec, std::array> - find_triangle_hit (const sm::mat44& model_to_scene, + find_triangle_hit (const sm::mat& model_to_scene, const sm::vec& camloc_mf, const sm::vec& vdir, const std::array ti_ml = {std::numeric_limits::max()}) { @@ -903,10 +903,10 @@ namespace mplot * triangle we hit; and the indices of the triangle we hit. */ std::tuple, sm::vec, std::array> - find_triangle_hit (const sm::mat44& camspace, const sm::mat44& model_to_scene, + find_triangle_hit (const sm::mat& camspace, const sm::mat& model_to_scene, const float search_dist_mult = 1.0f) { - sm::mat44 scene_to_model = model_to_scene.inverse(); + sm::mat scene_to_model = model_to_scene.inverse(); // use camera location in gltf to start from, then find model surface. sm::vec camloc_mf = (scene_to_model * camspace * sm::vec{}).less_one_dim(); sm::vec vdir = this->bb.mid() - camloc_mf; @@ -919,21 +919,21 @@ namespace mplot * Position the camera hoverheight above the location hp_scene, with its forward direction * _z and its 'x' axis in direction _x. */ - sm::mat44 position_camera (const sm::vec& hp_scene, const sm::mat44& model_to_scene, - const sm::vec& _x, const sm::vec& _z, - const float hoverheight) + sm::mat position_camera (const sm::vec& hp_scene, const sm::mat& model_to_scene, + const sm::vec& _x, const sm::vec& _z, + const float hoverheight) { // I think this positions correctly now (which is all it has to do). It ignores scaling - // in model_to_scene. Can be reduced to use fewer mat44s. - sm::mat44 cam_mv_y; + // in model_to_scene. Can be reduced to use fewer mat<>s. + sm::mat cam_mv_y; cam_mv_y.translate (sm::vec{0, hoverheight, 0}); // The basis _x, tn0, _z, where these are vectors in the model frame that define a camera frame - sm::mat44 cam_to_model_rotn = sm::mat44::frombasis (_x, this->tn0, _z); + sm::mat cam_to_model_rotn = sm::mat::frombasis (_x, this->tn0, _z); // Get the rotation from scene frame to model - sm::mat44 m_to_sc_rotn = model_to_scene.rotation_mat44(); - sm::mat44 hp_m; + sm::mat m_to_sc_rotn = model_to_scene.rotation_mat44(); + sm::mat hp_m; hp_m.translate (hp_scene); - sm::mat44 coord_rotn = hp_m * m_to_sc_rotn * cam_to_model_rotn * cam_mv_y; + sm::mat coord_rotn = hp_m * m_to_sc_rotn * cam_to_model_rotn * cam_mv_y; return coord_rotn; } @@ -946,13 +946,13 @@ namespace mplot * with its y-axis in line with the normal of the triangle at the hit point, and with its x * and z axes randomly oriented. The frame is set to hover hoverheight 'above' the triangle */ - sm::mat44 position_camera (const sm::vec& hp_scene, const sm::mat44& model_to_scene, - const float hoverheight) + sm::mat position_camera (const sm::vec& hp_scene, const sm::mat& model_to_scene, + const float hoverheight) { // Let's 'draw' the camera towards the model and then arrange its normal upwards wrt to the normal of the model. if (this->tn0[0] == std::numeric_limits::max()) { std::cout << __func__ << ": No hit/triangle normal\n"; - return sm::mat44{}; + return sm::mat{}; } // Place the camera on the model, and orient it randomly in the 'model plane' @@ -971,13 +971,13 @@ namespace mplot * A version of position camera that aligns the camera direction (i.e. where it is looking - its 'forwards') * as closely as possible with the passed-in vector */ - sm::mat44 position_camera (const sm::vec& hp_scene, const sm::mat44& model_to_scene, - const float hoverheight, const sm::vec& fwds) + sm::mat position_camera (const sm::vec& hp_scene, const sm::mat& model_to_scene, + const float hoverheight, const sm::vec& fwds) { // Let's 'draw' the camera towards the model and then arrange its normal upwards wrt to the normal of the model. if (this->tn0[0] == std::numeric_limits::max()) { std::cout << __func__ << ": No hit/triangle normal\n"; - return sm::mat44{}; + return sm::mat{}; } // Project fwds onto the plane tn0 @@ -1002,10 +1002,10 @@ namespace mplot * * \return The re-positioned camera transform matrix */ - sm::mat44 compute_mesh_movement (const sm::vec& mv_camframe, - const sm::mat44& cam_to_scene, - const sm::mat44& model_to_scene, - const float hoverheight) + sm::mat compute_mesh_movement (const sm::vec& mv_camframe, + const sm::mat& cam_to_scene, + const sm::mat& model_to_scene, + const float hoverheight) { constexpr bool debug_move = false; constexpr bool debug_move2 = true; @@ -1049,7 +1049,7 @@ namespace mplot std::tie (isect, hov_sf) = sm::geometry::ray_tri_intersection (tv_sf[0], tv_sf[1], tv_sf[2], camloc_sf + (this->tn0 / 2.0f), -this->tn0); // Use the detected location, hov_sf to compute the surface location of the camera - its 'hover location' - sm::mat44 cam_to_surface = cam_to_scene; + sm::mat cam_to_surface = cam_to_scene; cam_to_surface.pretranslate (hov_sf - camloc_sf); // This is now our init pose; the camera is now at the surface // Try double precision @@ -1309,7 +1309,7 @@ namespace mplot if (stabilised == false) { this->tn0.angle (_tn, cd.tri_edge); } // If tn0 and _tn are identical, then rotn_angle will be NaN, but in that case we want no rotation if (std::isnan (rotn_angle)) { rotn_angle = 0.0f; } - sm::mat44 reorient_model; // reorientation transformation in sf + sm::mat reorient_model; // reorientation transformation in sf reorient_model.rotate (cd.tri_edge, rotn_angle); sm::vec mv_rest = (reorient_model * (mv_inplane - cd.pm.mv)).less_one_dim(); reorient_model.pretranslate (hov_sf + cd.pm.mv + mv_rest); @@ -1457,7 +1457,7 @@ namespace mplot for (auto onen : onens) { // Are we in this one? auto [_ti, _tn] = onen; - sm::vec, 3> tv_nb = this->triangle_vertices (_ti, model_to_scene); + sm::vec, 3> tv_nb = this->triangle_vertices (_ti, model_to_scene); _tn = this->triangle_normal (tv_nb); auto [is, h] = sm::geometry::ray_tri_intersection (tv_nb[0], tv_nb[1], tv_nb[2], hov_sf + (_tn / 2.0f), -_tn); sm::vec mv_orthog_nb = _tn * (mv_inplane.dot (_tn) / (_tn.dot(_tn))); diff --git a/mplot/QuiverVisual.h b/mplot/QuiverVisual.h index 52f9edec..8e0b4454 100644 --- a/mplot/QuiverVisual.h +++ b/mplot/QuiverVisual.h @@ -86,7 +86,7 @@ namespace mplot // Now scale the lengths for their size on screen. Do this with a linear or log scaling. // (if log) First replace zeros with NaNs so that log transform will work. - if (this->do_quiver_length_scaling == true && this->length_scale.getType() == sm::scaling_function::Logarithmic) { + if (this->do_quiver_length_scaling == true && this->length_scale.get_type() == sm::scaling_function::Logarithmic) { dlengths.search_replace (Flt{0}, std::numeric_limits::quiet_NaN()); } diff --git a/mplot/RectangleVisual.h b/mplot/RectangleVisual.h index e8934b10..4163b1da 100644 --- a/mplot/RectangleVisual.h +++ b/mplot/RectangleVisual.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include namespace mplot @@ -47,7 +47,7 @@ namespace mplot c4 /= 2.0f; // Apply rotational transformation - sm::mat22 rotn; + sm::mat rotn; rotn.rotate (this->angle * sm::mathconst::deg2rad); c1 = rotn * c1; c2 = rotn * c2; diff --git a/mplot/ScatterVisual.h b/mplot/ScatterVisual.h index 98d3e9af..bf65af49 100644 --- a/mplot/ScatterVisual.h +++ b/mplot/ScatterVisual.h @@ -25,7 +25,7 @@ namespace mplot ScatterVisual(const sm::vec _offset) { this->viewmatrix.translate (_offset); - this->zScale.setParams (1, 0); + this->zScale.set_params (1, 0); this->colourScale.do_autoscale = true; } diff --git a/mplot/VerticesVisual.h b/mplot/VerticesVisual.h index 39753ea6..34513f36 100644 --- a/mplot/VerticesVisual.h +++ b/mplot/VerticesVisual.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -7,6 +8,8 @@ #include #include +#include +#include #include @@ -21,7 +24,7 @@ namespace mplot template struct VerticesVisual : public VisualModel { - VerticesVisual (sm::mat44& _model_transform, + VerticesVisual (sm::mat& _model_transform, sm::vvec _ind, sm::vvec> _posn, sm::vvec> _norm, diff --git a/mplot/VisualBase.h b/mplot/VisualBase.h index c2caa54a..eb9c557b 100644 --- a/mplot/VisualBase.h +++ b/mplot/VisualBase.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -555,9 +555,9 @@ namespace mplot //! Set sceneview and sceneview_tr back to scenetrans_default void reset_sceneviews_to_scenetrans_default() { - this->sceneview.setToIdentity(); + this->sceneview.set_identity(); this->sceneview.translate (this->scenetrans_default); - this->sceneview_tr.setToIdentity(); + this->sceneview_tr.set_identity(); this->sceneview_tr.translate (this->scenetrans_default); this->d_to_rotation_centre = -this->scenetrans_default[2]; } @@ -793,7 +793,7 @@ namespace mplot // Calculate aspect ratio float aspect = static_cast(this->window_w) / static_cast(this->window_h ? this->window_h : 1); // Set perspective projection - this->projection = sm::mat44::perspective (this->fov, aspect, this->zNear, this->zFar); + this->projection = sm::mat::perspective (this->fov, aspect, this->zNear, this->zFar); // Compute the inverse projection matrix this->invproj = this->projection.inverse(); } @@ -809,15 +809,15 @@ namespace mplot */ void setOrthographic() { - this->projection = sm::mat44::orthographic (this->ortho_lb, this->ortho_rt, this->zNear, this->zFar); + this->projection = sm::mat::orthographic (this->ortho_lb, this->ortho_rt, this->zNear, this->zFar); this->invproj = this->projection.inverse(); } // Rotate about the point this->rotation_centre. Subroutine for computeSceneview. void computeSceneview_about_rotation_centre() { - sm::mat44 sv_tr; - sm::mat44 sv_rot; + sm::mat sv_tr; + sm::mat sv_rot; if (this->ptype == perspective_type::orthographic || this->ptype == perspective_type::perspective) { sv_tr.translate (this->scenetrans_delta); // A rotation delta in world frame about the 'screen centre' @@ -872,7 +872,7 @@ namespace mplot mplot::VisualModel* followedVM = nullptr; //! Holds the viewmatrix of the followedVM the last time we called render - sm::mat44 followedLastViewMatrix; + sm::mat followedLastViewMatrix; // Initialize OpenGL shaders, set some flags (Alpha, Anti-aliasing), read in any external // state from json, and set up the coordinate arrows and any VisualTextModels that will be @@ -897,10 +897,10 @@ namespace mplot this->rotation_default.y = vconf.contains("scenerotn_y") ? vconf["scenerotn_y"].get() : this->rotation_default.y; this->rotation_default.z = vconf.contains("scenerotn_z") ? vconf["scenerotn_z"].get() : this->rotation_default.z; - this->sceneview.setToIdentity(); + this->sceneview.set_identity(); this->sceneview.translate (this->scenetrans_default); this->sceneview.rotate (this->rotation_default); - this->sceneview_tr.setToIdentity(); + this->sceneview_tr.set_identity(); this->sceneview_tr.translate (this->scenetrans_default); this->scenetrans_delta.zero(); this->rotation_delta.reset(); @@ -970,23 +970,23 @@ namespace mplot float d_to_rotation_centre = -zDefault; //! The projection matrix is a member of this class. Value is set during setPerspective() or setOrthographic() - sm::mat44 projection; + sm::mat projection; //! The inverse of the projection. Value is set during setPerspective() or setOrthographic() - sm::mat44 invproj; + sm::mat invproj; //! The sceneview matrix, which changes as the user moves the view with mouse //! movements. Initialized in VisualOwnable(No)MX constructor. - sm::mat44 sceneview; + sm::mat sceneview; //! The non-rotating sceneview matrix, updated only from mouse translations (avoiding rotations) - sm::mat44 sceneview_tr; + sm::mat sceneview_tr; //! Saved sceneview at mouse button down - sm::mat44 savedSceneview; + sm::mat savedSceneview; //! Saved sceneview_tr - sm::mat44 savedSceneview_tr; + sm::mat savedSceneview_tr; public: @@ -1208,8 +1208,8 @@ namespace mplot // Reset translation this->cyl_cam_pos = this->cyl_cam_pos_default; - this->sceneview.setToIdentity(); - this->sceneview_tr.setToIdentity(); + this->sceneview.set_identity(); + this->sceneview_tr.set_identity(); this->sceneview.translate (this->scenetrans_default); this->sceneview.rotate (this->rotation_default); this->sceneview_tr.translate (this->scenetrans_default); @@ -1618,7 +1618,7 @@ namespace mplot this->d_to_rotation_centre -= this->scenetrans_delta[2]; // Translate scroll_move_y then add it to cyl_cam_pos here - sm::mat44 sceneview_rotn (this->sceneview.linear()); + sm::mat sceneview_rotn (this->sceneview.linear()); this->cyl_cam_pos += sceneview_rotn * scroll_move_y; } return true; // needs_render diff --git a/mplot/VisualCommon.h b/mplot/VisualCommon.h index 7e5f6325..5437cf53 100644 --- a/mplot/VisualCommon.h +++ b/mplot/VisualCommon.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -24,7 +24,7 @@ namespace mplot struct meshgroup { std::string name; - sm::mat44 transform; + sm::mat transform; sm::vvec indices; sm::vvec> positions; sm::vvec> normals; diff --git a/mplot/VisualModelBase.h b/mplot/VisualModelBase.h index c2e65d8f..88cda242 100644 --- a/mplot/VisualModelBase.h +++ b/mplot/VisualModelBase.h @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include @@ -409,19 +409,19 @@ namespace mplot virtual void render() = 0; //! Setter for the viewmatrix - void setViewMatrix (const sm::mat44& mv) { this->viewmatrix = mv; } + void setViewMatrix (const sm::mat& mv) { this->viewmatrix = mv; } //! And a getter - sm::mat44 getViewMatrix() const { return this->viewmatrix; } + sm::mat getViewMatrix() const { return this->viewmatrix; } //! Pre or post-multiply - void postmultViewMatrix (const sm::mat44& m) { this->viewmatrix = this->viewmatrix * m; } - void premultViewMatrix (const sm::mat44& m) { this->viewmatrix = m * this->viewmatrix; } + void postmultViewMatrix (const sm::mat& m) { this->viewmatrix = this->viewmatrix * m; } + void premultViewMatrix (const sm::mat& m) { this->viewmatrix = m * this->viewmatrix; } void scaleViewMatrix (const float by) { this->viewmatrix.scale (by); } - virtual void setSceneMatrixTexts (const sm::mat44& sv) = 0; + virtual void setSceneMatrixTexts (const sm::mat& sv) = 0; //! When setting the scene matrix, also have to set the text's scene matrices. - void setSceneMatrix (const sm::mat44& sv) + void setSceneMatrix (const sm::mat& sv) { this->scenematrix = sv; this->setSceneMatrixTexts (sv); @@ -433,7 +433,7 @@ namespace mplot template requires (N == 3) || (N == 4) void setSceneTranslation (const sm::vec& v0) { - this->scenematrix.setToIdentity(); + this->scenematrix.set_identity(); this->scenematrix.translate (v0); if constexpr (N == 4) { this->setSceneTranslationTexts (v0.less_one_dim()); @@ -449,7 +449,7 @@ namespace mplot //! Set a rotation (only) into the scene view matrix void setSceneRotation (const sm::quaternion& r) { - this->scenematrix.setToIdentity(); + this->scenematrix.set_identity(); this->scenematrix.rotate (r); } @@ -460,7 +460,7 @@ namespace mplot template requires (N == 3) || (N == 4) void setViewTranslation (const sm::vec& v0) { - this->viewmatrix.setToIdentity(); + this->viewmatrix.set_identity(); this->viewmatrix.translate (v0); } @@ -472,7 +472,7 @@ namespace mplot void setViewRotationFixTexts (const sm::quaternion& r) { sm::vec<> os = this->viewmatrix.translation(); - this->viewmatrix.setToIdentity(); + this->viewmatrix.set_identity(); this->viewmatrix.translate (os); this->viewmatrix.rotate (r); } @@ -483,7 +483,7 @@ namespace mplot void setViewRotation (const sm::quaternion& r) { sm::vec<> os = this->viewmatrix.translation(); - this->viewmatrix.setToIdentity(); + this->viewmatrix.set_identity(); this->viewmatrix.translate (os); this->viewmatrix.rotate (r); this->setViewRotationTexts (r); @@ -826,14 +826,14 @@ namespace mplot protected: //! The model-specific view matrix. Used to transform the pose of the model in the scene. - sm::mat44 viewmatrix = {}; + sm::mat viewmatrix = {}; /*! * The scene view matrix. Each VisualModel has a copy of the scenematrix. It's set in * Visual::render. Different VisualModels may have different scenematrices (for example, the * CoordArrows has a different scenematrix from other VisualModels, and models marked * 'twodimensional' also have a different scenematrix). */ - sm::mat44 scenematrix = {}; + sm::mat scenematrix = {}; //! Contains the positions within the vbo array of the different vertex buffer objects enum VBOPos { posnVBO, normVBO, colVBO, idxVBO, numVBO }; @@ -2096,7 +2096,7 @@ namespace mplot std::array sc2, sm::vec abc, int rings = 10, int segments = 12, - sm::mat44 tr = sm::mat44{}) + sm::mat tr = sm::mat{}) { // We have two angular parameters t and t2. t in range 0-2pi and t2 in range 0-pi. t // gives the 'xy' ellipse; t2 gives the change in size of the xy ellipse as the z axis diff --git a/mplot/VisualModelImplMX.h b/mplot/VisualModelImplMX.h index 861b0a4d..67fdb9a4 100644 --- a/mplot/VisualModelImplMX.h +++ b/mplot/VisualModelImplMX.h @@ -295,11 +295,11 @@ namespace mplot // The scene-view matrix GLint loc_v = _glfn->GetUniformLocation (this->get_gprog(this->parentVis), static_cast("v_matrix")); - if (loc_v != -1) { _glfn->UniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.mat.data()); } + if (loc_v != -1) { _glfn->UniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.arr.data()); } // the model-view matrix GLint loc_m = _glfn->GetUniformLocation (this->get_gprog(this->parentVis), static_cast("m_matrix")); - if (loc_m != -1) { _glfn->UniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.mat.data()); } + if (loc_m != -1) { _glfn->UniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.arr.data()); } if constexpr (debug_render) { std::cout << "VisualModel::render: scenematrix:\n" << this->scenematrix << std::endl; @@ -434,7 +434,7 @@ namespace mplot return this->texts.back()->getTextGeometry(); } - void setSceneMatrixTexts (const sm::mat44& sv) final + void setSceneMatrixTexts (const sm::mat& sv) final { auto ti = this->texts.begin(); while (ti != this->texts.end()) { (*ti)->setSceneMatrix (sv); ti++; } diff --git a/mplot/VisualModelImplNoMX.h b/mplot/VisualModelImplNoMX.h index 6ef6f8d2..00d0cb47 100644 --- a/mplot/VisualModelImplNoMX.h +++ b/mplot/VisualModelImplNoMX.h @@ -285,11 +285,11 @@ namespace mplot // The scene-view matrix GLint loc_v = glGetUniformLocation (this->get_gprog(this->parentVis), static_cast("v_matrix")); - if (loc_v != -1) { glUniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.mat.data()); } + if (loc_v != -1) { glUniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.arr.data()); } // the model-view matrix GLint loc_m = glGetUniformLocation (this->get_gprog(this->parentVis), static_cast("m_matrix")); - if (loc_m != -1) { glUniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.mat.data()); } + if (loc_m != -1) { glUniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.arr.data()); } if constexpr (debug_render) { std::cout << "VisualModelImpl::render: scenematrix:\n" << this->scenematrix << std::endl; @@ -425,7 +425,7 @@ namespace mplot return this->texts.back()->getTextGeometry(); } - void setSceneMatrixTexts (const sm::mat44& sv) final + void setSceneMatrixTexts (const sm::mat& sv) final { auto ti = this->texts.begin(); while (ti != this->texts.end()) { (*ti)->setSceneMatrix (sv); ti++; } diff --git a/mplot/VisualOwnableMX.h b/mplot/VisualOwnableMX.h index 6b67f6c8..4ddd1a3f 100644 --- a/mplot/VisualOwnableMX.h +++ b/mplot/VisualOwnableMX.h @@ -231,14 +231,14 @@ namespace mplot // Switch to text shader program and set the projection matrix this->glfn->UseProgram (this->shaders.tprog); GLint loc_p = this->glfn->GetUniformLocation (this->shaders.tprog, static_cast("p_matrix")); - if (loc_p != -1) { this->glfn->UniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.mat.data()); } + if (loc_p != -1) { this->glfn->UniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.arr.data()); } // Switch back to the regular shader prog and render the VisualModels. this->glfn->UseProgram (this->shaders.gprog); // Set the projection matrix just once loc_p = this->glfn->GetUniformLocation (this->shaders.gprog, static_cast("p_matrix")); - if (loc_p != -1) { this->glfn->UniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.mat.data()); } + if (loc_p != -1) { this->glfn->UniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.arr.data()); } if ((this->ptype == perspective_type::orthographic || this->ptype == perspective_type::perspective) && this->options.test (visual_options::showCoordArrows)) { diff --git a/mplot/VisualOwnableNoMX.h b/mplot/VisualOwnableNoMX.h index af8f7d41..4dd54466 100644 --- a/mplot/VisualOwnableNoMX.h +++ b/mplot/VisualOwnableNoMX.h @@ -225,14 +225,14 @@ namespace mplot // Switch to text shader program and set the projection matrix glUseProgram (this->shaders.tprog); GLint loc_p = glGetUniformLocation (this->shaders.tprog, static_cast("p_matrix")); - if (loc_p != -1) { glUniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.mat.data()); } + if (loc_p != -1) { glUniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.arr.data()); } // Switch back to the regular shader prog and render the VisualModels. glUseProgram (this->shaders.gprog); // Set the projection matrix just once loc_p = glGetUniformLocation (this->shaders.gprog, static_cast("p_matrix")); - if (loc_p != -1) { glUniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.mat.data()); } + if (loc_p != -1) { glUniformMatrix4fv (loc_p, 1, GL_FALSE, this->projection.arr.data()); } if ((this->ptype == perspective_type::orthographic || this->ptype == perspective_type::perspective) && this->options.test (visual_options::showCoordArrows)) { diff --git a/mplot/VisualTextModelBase.h b/mplot/VisualTextModelBase.h index 92b734ad..a834faac 100644 --- a/mplot/VisualTextModelBase.h +++ b/mplot/VisualTextModelBase.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -61,16 +61,16 @@ namespace mplot } //! Setter for VisualTextModel::viewmatrix, the model view - void setViewMatrix (const sm::mat44& mv) { this->viewmatrix = mv; } + void setViewMatrix (const sm::mat& mv) { this->viewmatrix = mv; } //! Setter for VisualTextModel::scenematrix, the scene view - void setSceneMatrix (const sm::mat44& sv) { this->scenematrix = sv; } + void setSceneMatrix (const sm::mat& sv) { this->scenematrix = sv; } //! Set the translation specified by \a v0 into the scene translation template requires (N == 3) || (N == 4) void setSceneTranslation (const sm::vec& v0) { - this->scenematrix.setToIdentity(); + this->scenematrix.set_identity(); this->scenematrix.translate (v0); } @@ -82,7 +82,7 @@ namespace mplot void setSceneRotation (const sm::quaternion& r) { auto _offset = this->scenematrix.translation(); - this->scenematrix.setToIdentity(); + this->scenematrix.set_identity(); this->scenematrix.translate (_offset); this->scenematrix.rotate (r); } @@ -94,7 +94,7 @@ namespace mplot template requires (N == 3) || (N == 4) void setViewTranslation (const sm::vec& v0) { - this->viewmatrix.setToIdentity(); + this->viewmatrix.set_identity(); this->viewmatrix.translate (v0); } @@ -105,7 +105,7 @@ namespace mplot void setViewRotation (const sm::quaternion& r) { auto tr = this->viewmatrix.translation(); - this->viewmatrix.setToIdentity(); + this->viewmatrix.set_identity(); this->viewmatrix.translate (tr); this->viewmatrix.rotate (r); } @@ -254,12 +254,12 @@ namespace mplot sm::quaternion parent_rotation = {}; //! The text-model-specific view matrix and a scene matrix - sm::mat44 viewmatrix = {}; + sm::mat viewmatrix = {}; //! Before, I wrote: We protect the scene matrix as updating it with the parent //! model's scene matrix likely involves also adding an additional //! translation. Now, I'm still slightly confused as to whether I *need* to have a //! copy of the scenematrix *here*. - sm::mat44 scenematrix = {}; + sm::mat scenematrix = {}; //! The text string stored for debugging std::basic_string txt; diff --git a/mplot/VisualTextModelImplMX.h b/mplot/VisualTextModelImplMX.h index 80e6a912..c8e1a76f 100644 --- a/mplot/VisualTextModelImplMX.h +++ b/mplot/VisualTextModelImplMX.h @@ -68,9 +68,9 @@ namespace mplot GLint loc_a = _glfn->GetUniformLocation (tshaderprog, static_cast("alpha")); if (loc_a != -1) { _glfn->Uniform1f (loc_a, this->alpha); } GLint loc_v = _glfn->GetUniformLocation (tshaderprog, static_cast("v_matrix")); - if (loc_v != -1) { _glfn->UniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.mat.data()); } + if (loc_v != -1) { _glfn->UniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.arr.data()); } GLint loc_m = _glfn->GetUniformLocation (tshaderprog, static_cast("m_matrix")); - if (loc_m != -1) { _glfn->UniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.mat.data()); } + if (loc_m != -1) { _glfn->UniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.arr.data()); } _glfn->ActiveTexture (GL_TEXTURE0); diff --git a/mplot/VisualTextModelImplNoMX.h b/mplot/VisualTextModelImplNoMX.h index 35ae8241..e98e9d19 100644 --- a/mplot/VisualTextModelImplNoMX.h +++ b/mplot/VisualTextModelImplNoMX.h @@ -65,9 +65,9 @@ namespace mplot GLint loc_a = glGetUniformLocation (tshaderprog, static_cast("alpha")); if (loc_a != -1) { glUniform1f (loc_a, this->alpha); } GLint loc_v = glGetUniformLocation (tshaderprog, static_cast("v_matrix")); - if (loc_v != -1) { glUniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.mat.data()); } + if (loc_v != -1) { glUniformMatrix4fv (loc_v, 1, GL_FALSE, this->scenematrix.arr.data()); } GLint loc_m = glGetUniformLocation (tshaderprog, static_cast("m_matrix")); - if (loc_m != -1) { glUniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.mat.data()); } + if (loc_m != -1) { glUniformMatrix4fv (loc_m, 1, GL_FALSE, this->viewmatrix.arr.data()); } glActiveTexture (GL_TEXTURE0); diff --git a/mplot/VoronoiVisual.h b/mplot/VoronoiVisual.h index 72965e28..1e990237 100644 --- a/mplot/VoronoiVisual.h +++ b/mplot/VoronoiVisual.h @@ -62,7 +62,7 @@ namespace mplot VoronoiVisual (const sm::vec _offset) { this->viewmatrix.translate (_offset); - this->zScale.setParams (1, 0); + this->zScale.set_params (1, 0); this->colourScale.do_autoscale = true; this->colourScale2.do_autoscale = true; this->colourScale3.do_autoscale = true; @@ -143,7 +143,7 @@ namespace mplot arma::princomp (co, sc, lat, tsq, x); // Mat access is (r, c) sm::vec pc1vec = { co(0, 0), co(1, 0) }; - sm::mat22 el_rotn; + sm::mat el_rotn; el_rotn.rotate (pc1vec.angle()); float a = this->n_sigma * std::sqrt (lat(0)); float b = this->n_sigma * std::sqrt (lat(1)); diff --git a/mplot/compoundray/EyeVisual.h b/mplot/compoundray/EyeVisual.h index 1b3fc42d..bcea798a 100644 --- a/mplot/compoundray/EyeVisual.h +++ b/mplot/compoundray/EyeVisual.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -184,7 +185,7 @@ namespace mplot::compoundray struct projection_data { // Use this to position the 2D map wrt the three D model. You can translate, scale and rotate - sm::mat44 twod_transform; + sm::mat twod_transform; // The user-provided radius of the projection sphere. Will need to match the size of the compound ray eye float proj_radius = 0.0f; // The centre of the user-provided projection sphere or cylinder @@ -210,7 +211,7 @@ namespace mplot::compoundray // A compound eye visualization may require several projections to 2D std::vector projections; - void add_spherical_projection (projection_type t, const sm::mat44& _twod_transform, + void add_spherical_projection (projection_type t, const sm::mat& _twod_transform, const sm::vec& centre, const float radius, const sm::quaternion rotn = sm::quaternion(), const uint32_t _start_i = 0, @@ -234,12 +235,12 @@ namespace mplot::compoundray const uint32_t _start_i = 0, const uint32_t _end_i = std::numeric_limits::max()) { - sm::mat44 tr; + sm::mat tr; tr.translate (_twod_offset); this->add_spherical_projection (t, tr, centre, radius, rotn, _start_i, _end_i); } - void add_cylindrical_projection (const sm::mat44& _twod_transform, const sm::vec& centre, + void add_cylindrical_projection (const sm::mat& _twod_transform, const sm::vec& centre, const float radius, const float height, const uint32_t _start_i = 0, const uint32_t _end_i = std::numeric_limits::max()) @@ -388,7 +389,7 @@ namespace mplot::compoundray // Rotate coordinates as the compound eye looks forwards along z, whereas 2D // projections look forwards along x by convention. - sm::mat44 coord_rotn; + sm::mat coord_rotn; coord_rotn.rotate (sm::vec<>::uz(), sm::mathconst::pi_over_2); coord_rotn.rotate (sm::vec<>::ux(), sm::mathconst::pi_over_2); diff --git a/mplot/compoundray/interop.h b/mplot/compoundray/interop.h index 0be3e4ac..134abc9f 100644 --- a/mplot/compoundray/interop.h +++ b/mplot/compoundray/interop.h @@ -14,7 +14,7 @@ // maths and mathplot includes #include -#include +#include #include #include @@ -23,8 +23,8 @@ extern MulticamScene* scene; namespace mplot::compoundray { - // Helper to convert sm::mat44 to Matrix4x4 - sutil::Matrix4x4 mat44_to_Matrix4x4 (const sm::mat44& m) + // Helper to convert sm::mat to Matrix4x4 + sutil::Matrix4x4 mat44_to_Matrix4x4 (const sm::mat& m) { sutil::Matrix4x4 M = {}; // M is row-major, m is col-major M[0] = m[0]; M[1] = m[4]; M[2] = m[8]; M[3] = m[12]; @@ -43,7 +43,7 @@ namespace mplot::compoundray constexpr sm::vec ux = { 1.0f, 0.0f, 0.0f }; constexpr sm::vec uy = { 0.0f, 1.0f, 0.0f }; constexpr sm::vec uz = { 0.0f, 0.0f, 1.0f }; - sm::mat44 world_transform = sm::mat44::frombasis (ux, uz, -uy); + sm::mat world_transform = sm::mat::frombasis (ux, uz, -uy); return mplot::compoundray::mat44_to_Matrix4x4 (world_transform); } @@ -58,7 +58,7 @@ namespace mplot::compoundray std::vector> mymeshes = thescene->getMeshes(); std::vector mymats = thescene->getMaterials(); for (unsigned int mi = 0; mi < mymeshes.size(); ++mi) { - sm::mat44 tfm; + sm::mat tfm; for (unsigned int tfi = 0; tfi < 16; ++tfi) { tfm[tfi] = mymeshes[mi]->transform[tfi]; } tfm.transpose_inplace(); // Need to transpose tfm after copying data if constexpr (debug_meshload) { @@ -149,7 +149,7 @@ namespace mplot::compoundray } // From the camera localspace, we can create a matrix which specifies a camera pose within the world frame - sm::mat44 getCameraSpace (MulticamScene* thescene) + sm::mat getCameraSpace (MulticamScene* thescene) { // The camera's localspace is a set of three vectors in world coordinates float3 camls_x, camls_y, camls_z; @@ -160,7 +160,7 @@ namespace mplot::compoundray sm::vec camls_zv = { camls_z.x, camls_z.y, camls_z.z }; // Start with setting the matrix from the localspace basis vectors - sm::mat44 camera_space = sm::mat44::frombasis (camls_xv, camls_yv, camls_zv); + sm::mat camera_space = sm::mat::frombasis (camls_xv, camls_yv, camls_zv); // Translate camera_space by the camera position, obtained from compound-ray float3 campos = thescene->getCamera()->getPosition(); diff --git a/tests/testVisRemoveModel.cpp b/tests/testVisRemoveModel.cpp index 37e2af53..43eec891 100644 --- a/tests/testVisRemoveModel.cpp +++ b/tests/testVisRemoveModel.cpp @@ -58,7 +58,7 @@ int main (int argc, char** argv) offset = { 0.0, 0.1, 0.0 }; sm::scale scale; - scale.setParams (1.0, 0.0); + scale.set_params (1.0, 0.0); std::vector> points; points.push_back ({0,0,0}); diff --git a/tests/test_circleboundary.cpp b/tests/test_circleboundary.cpp index 654f7298..48c1deee 100644 --- a/tests/test_circleboundary.cpp +++ b/tests/test_circleboundary.cpp @@ -49,7 +49,7 @@ int main (int argc, char** argv) v.bindmodel (hgv); hgv->setScalarData (&data); hgv->cm.setType (mplot::ColourMapType::Rainbow); - hgv->zScale.setParams(0,0); + hgv->zScale.set_params(0,0); hgv->finalize(); v.addVisualModel (hgv); v.render(); diff --git a/tests/test_ellipseboundary.cpp b/tests/test_ellipseboundary.cpp index e9e25047..cdaa6571 100644 --- a/tests/test_ellipseboundary.cpp +++ b/tests/test_ellipseboundary.cpp @@ -49,7 +49,7 @@ int main (int argc, char** argv) v.bindmodel (hgv); hgv->setScalarData (&data); hgv->cm.setType (mplot::ColourMapType::Magma); - hgv->zScale.setParams (0.0f, 0.0f); + hgv->zScale.set_params (0.0f, 0.0f); hgv->finalize(); v.addVisualModel (hgv); v.render(); diff --git a/tests/testbighexgrid.cpp b/tests/testbighexgrid.cpp index e672d2d5..518246e8 100644 --- a/tests/testbighexgrid.cpp +++ b/tests/testbighexgrid.cpp @@ -49,7 +49,7 @@ int main() v.bindmodel (hgv); hgv->hexVisMode = mplot::HexVisMode::Triangles; // Triangles faster to render than the default hexes hgv->setScalarData (&data); - hgv->zScale.setParams (0.1f, 0.0f); + hgv->zScale.set_params (0.1f, 0.0f); hgv->finalize(); v.addVisualModel (hgv); diff --git a/tests/testhexgrid3.cpp b/tests/testhexgrid3.cpp index ee88146f..60f77950 100644 --- a/tests/testhexgrid3.cpp +++ b/tests/testhexgrid3.cpp @@ -59,7 +59,7 @@ int main() } } hgv->cm.setType (mplot::ColourMapType::Jet); - hgv->zScale.setParams (0,0); // makes the output flat in z direction, but you still get the colours + hgv->zScale.set_params (0,0); // makes the output flat in z direction, but you still get the colours hgv->setScalarData (&colours); hgv->hexVisMode = mplot::HexVisMode::HexInterp; // Or mplot::HexVisMode::Triangles for a smoother surface plot hgv->finalize(); diff --git a/tests/testhexgridsave.cpp b/tests/testhexgridsave.cpp index b0861995..64588659 100644 --- a/tests/testhexgridsave.cpp +++ b/tests/testhexgridsave.cpp @@ -82,7 +82,7 @@ int main() } } hgv->cm.setType (mplot::ColourMapType::Jet); - hgv->zScale.setParams (0,0); // makes the output flat in z direction, but you still get the colours + hgv->zScale.null_scaling(); // makes the output flat in z direction, but you still get the colours hgv->setScalarData (&colours); hgv->hexVisMode = mplot::HexVisMode::HexInterp; // Or mplot::HexVisMode::Triangles for a smoother surface plot hgv->finalize();