NEML2 2.0.0
Loading...
Searching...
No Matches
Rot.h
1// Copyright 2024, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#pragma once
26
27#include "neml2/tensors/VecBase.h"
28
29namespace neml2
30{
31// Forward declarations
32class Scalar;
33class Vec;
34class R2;
35class R3;
36
48class Rot : public VecBase<Rot>
49{
50public:
51 using VecBase<Rot>::VecBase;
52
53 Rot(const Vec & v);
54
56 [[nodiscard]] static Rot
57 identity(const torch::TensorOptions & options = default_tensor_options());
58
60 static Rot fill_euler_angles(const torch::Tensor & vals,
61 const std::string & angle_convention,
62 const std::string & angle_type);
63
65 static Rot fill_matrix(const R2 & M);
66
68 static Rot fill_random(unsigned int n, Size random_seed);
69
71 static Rot fill_rodrigues(const Scalar & rx, const Scalar & ry, const Scalar & rz);
72
74 Rot inverse() const;
75
77 R2 euler_rodrigues() const;
78
80 R3 deuler_rodrigues() const;
81
83 Rot rotate(const Rot & r) const;
84
86 R2 drotate(const Rot & r) const;
87
89 R2 drotate_self(const Rot & r) const;
90
92 Rot shadow() const;
93
95 R2 dshadow() const;
96
98 Scalar dist(const Rot & r) const;
99
101 Scalar gdist(const Rot & r) const;
102
104 Scalar dV() const;
105};
106
108// So this follows the "matrix" convention where it's exactly the same
109// as the standard matrix product R1 * R2 where R1 and R2 are the
110// matrix representations of r1 and r2
111Rot operator*(const Rot & r1, const Rot & r2);
112
113} // namespace neml2
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:54
Second order tensor without symmetry.
Definition R2.h:42
Third order tensor without symmetry.
Definition R3.h:41
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
static Rot fill_euler_angles(const torch::Tensor &vals, const std::string &angle_convention, const std::string &angle_type)
Fill from an array of Euler angles.
Definition Rot.cxx:51
Rot rotate(const Rot &r) const
Rotate.
Definition Rot.cxx:185
static Rot fill_rodrigues(const Scalar &rx, const Scalar &ry, const Scalar &rz)
Fill from standard Rodrigues parameters.
Definition Rot.cxx:122
Scalar dist(const Rot &r) const
Distance measure between two rotations, accounting for shadow mapping.
Definition Rot.cxx:235
R3 deuler_rodrigues() const
d(R2)/d(r) – useful in constructing other derivatives
Definition Rot.cxx:170
Rot shadow() const
Return the shadow parameter set (a set of MRPs that define the same orientation)
Definition Rot.cxx:221
static Rot fill_random(unsigned int n, Size random_seed)
Fill some number of random orientations.
Definition Rot.cxx:134
R2 dshadow() const
Return the derivative of the shadow map.
Definition Rot.cxx:227
static Rot identity(const torch::TensorOptions &options=default_tensor_options())
The identity rotation, helpfully the zero vector.
Definition Rot.cxx:45
static Rot fill_matrix(const R2 &M)
Fill from rotation matrices.
Definition Rot.cxx:104
R2 euler_rodrigues() const
Generate a rotation matrix using the Euler-Rodrigues formula.
Definition Rot.cxx:159
R2 drotate_self(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. this vector.
Definition Rot.cxx:206
Scalar gdist(const Rot &r) const
Raw distance formula, not accounting for shadown mapping.
Definition Rot.cxx:244
Rot inverse() const
Inversion.
Definition Rot.cxx:153
Rot(const Vec &v)
Definition Rot.cxx:39
Scalar dV() const
Volume element at locations.
Definition Rot.cxx:251
R2 drotate(const Rot &r) const
Derivative of the rotated Rodrigues vector w.r.t. the other Rodrigues vector.
Definition Rot.cxx:191
Scalar.
Definition Scalar.h:38
Base class 3-vector.
Definition VecBase.h:43
3-vector.
Definition Vec.h:42
Definition CrossRef.cxx:31
Vec operator*(const Derived1 &A, const Derived2 &b)
matrix-vector product
Definition R2Base.cxx:233
torch::TensorOptions & default_tensor_options()
Definition types.cxx:157
int64_t Size
Definition types.h:33