PeriDEM 0.2.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 - 2024 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
14#include "util/transformation.h"
15
16#include <cstring> // string and size_t type
17#include <vector>
18
19namespace particle {
20
26
29
32
34 double d_theta;
35
37 double d_scale;
38
45 : d_translation(util::Point()), d_axis(util::Point()),
46 d_theta(0.), d_scale(1.){};
47
56 ParticleTransform(util::Point translate, util::Point axis, double theta,
57 double scale = 1.)
58 : d_translation(translate), d_axis(axis / axis.length()), d_theta(theta),
59 d_scale(scale){};
60
68
96 util::Point apply(const util::Point &v) const {
97
98 return d_translation +
100
101 // return d_translation + d_scale * util::Point(v.d_x, -v.d_y, 0.);
102 // return d_translation + v;
103 };
104
112 std::string printStr(int nt = 0, int lvl = 0) const {
113
114 auto tabS = util::io::getTabS(nt);
115 std::ostringstream oss;
116 oss << tabS << "------- ParticleTransform --------" << std::endl << std::endl;
117 oss << tabS << "Scale = " << d_scale << std::endl;
118 oss << tabS << "Angle = " << d_theta << std::endl;
119 oss << tabS << "Translation = " << d_translation.printStr() << std::endl;
120 oss << tabS << "Axis = " << d_axis.printStr() << std::endl;
121 oss << tabS << std::endl;
122
123 return oss.str();
124 }
125
132 void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); }
133};
134
135} // namespace particle
Collection of methods and data related to particle object.
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40
Collection of methods useful in simulation.
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....
void print(int nt=0, int lvl=0) const
Prints the information about the object.
double d_theta
Angle of rotation.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
util::Point d_translation
Translational vector.
util::Point apply(const util::Point &v) const
Returns the transformed vector. We assume that the passed vector passes through origin.
ParticleTransform(const ParticleTransform &t)
Copy constructor.
util::Point d_axis
Axis of rotation.
ParticleTransform(util::Point translate, util::Point axis, double theta, double scale=1.)
Constructor.
double d_scale
Volumetric scaling factor.
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