PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
particleTransform.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#pragma once
12
13#include "util/point.h" // definition of Point
15#include "util/io.h"
16
17#include <cstring> // string and size_t type
18#include <vector>
19
20namespace geom {
21
27
30
33
35 double d_theta;
36
38 double d_scale;
39
42
49 : d_translation(util::Point()), d_axis(util::Point()),
50 d_theta(0.), d_scale(1.), d_rotationPoint(util::Point()){};
51
60 ParticleTransform(util::Point translate, util::Point axis, double theta,
61 double scale = 1.)
62 : d_translation(translate), d_axis(axis / axis.length()), d_theta(theta),
63 d_scale(scale), d_rotationPoint(util::Point()){};
64
68 ParticleTransform(util::Point translate, util::Point axis, double theta, double scale,
69 util::Point rotation_point)
70 : d_translation(translate), d_axis(axis / axis.length()), d_theta(theta),
71 d_scale(scale), d_rotationPoint(rotation_point){};
72
80
97
105 std::string printStr(int nt = 0, int lvl = 0) const {
106
107 auto tabS = util::io::getTabS(nt);
108 std::ostringstream oss;
109 oss << tabS << "------- ParticleTransform --------" << std::endl << std::endl;
110 oss << tabS << "Scale = " << d_scale << std::endl;
111 oss << tabS << "Angle = " << d_theta << std::endl;
112 oss << tabS << "Translation = " << d_translation.printStr() << std::endl;
113 oss << tabS << "Rotation pivot = " << d_rotationPoint.printStr() << std::endl;
114 oss << tabS << "Axis = " << d_axis.printStr() << std::endl;
115 oss << tabS << std::endl;
116
117 return oss.str();
118 }
119
126 void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); }
127};
128
129} // namespace geom
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82
Collection of methods useful in simulation.
Definition constants.h:14
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.
A struct that stores transformation parameters and provides method to transform the particle....
util::Point apply(const util::Point &v) const
Maps a reference-configuration point to world coordinates using the same rule as geom::mapSimilarity...
double d_theta
Angle of rotation (radians)
ParticleTransform(util::Point translate, util::Point axis, double theta, double scale=1.)
Constructor with pivot at origin (reference mesh centered at origin).
util::Point d_rotationPoint
Pivot for rotation and scale (same role as rotationPoint in GeomObject::transform)....
void print(int nt=0, int lvl=0) const
Prints the information about the object.
util::Point d_translation
Rigid translation after rotate+scale about the pivot (matches GeomObject::transform).
ParticleTransform(const ParticleTransform &t)
Copy constructor.
double d_scale
Uniform scale factor.
util::Point d_axis
Unit axis of rotation.
ParticleTransform(util::Point translate, util::Point axis, double theta, double scale, util::Point rotation_point)
Constructor with explicit rotation pivot, as in GeomObject::transform.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
A structure to represent 3d vectors.
Definition point.h:30
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition point.h:94