11 const Eigen::Ref<const Coordinate::vector_type> &init_vec,
13 : m_home(&init_home) {
14 if (mode ==
FRAC) _set_frac(init_vec);
15 if (mode ==
CART) _set_cart(init_vec);
16 assert(m_home &&
"home lattice pointer was set to null!");
21 Coordinate::Coordinate(
double _x,
double _y,
double _z,
23 : m_home(&init_home) {
32 assert(
m_home &&
"home lattice pointer was set to null!");
45 assert(this->
m_home &&
"Home lattice is null");
46 assert(RHS.
m_home &&
"RHS home lattice is null");
92 }
else if (mode ==
CART) {
103 Eigen::IOFormat format)
const {
110 COORD_TYPE mode,
char term, Eigen::IOFormat format) {
115 stream << vec.transpose().format(format);
116 if (term) stream << term;
122 Eigen::IOFormat format)
const {
127 else if (mode ==
FRAC)
136 Eigen::IOFormat format)
const {
140 else if (mode ==
FRAC)
149 return (
cart() - neighbor.
cart()).norm();
157 assert(this->
m_home &&
"Home lattice is null");
158 assert(neighbor.
m_home &&
"Neighbor home lattice is null");
161 Eigen::Vector3d frac_lattice_translation =
164 translation.
frac() -= frac_lattice_translation;
170 double fast_result = translation.
const_cart().norm();
172 if (fast_result < (
home().inner_voronoi_radius() +
TOL))
return fast_result;
180 const Eigen::Ref<const Eigen::Matrix3d> &metric)
const {
182 tfrac -=
lround(tfrac).cast<
double>();
185 .
dot(metric * (
home().lat_column_mat() * tfrac));
193 assert(
m_home &&
"home lattice pointer was set to null!");
195 if (invariant_mode ==
CART)
197 else if (invariant_mode ==
FRAC)
208 bool was_within =
true;
210 for (
int i = 0; i < 3; i++) {
225 assert(
m_home &&
"home lattice pointer was set to null!");
228 bool was_within =
true;
230 for (
int i = 0; i < 3; i++) {
238 if (!was_within) (*this) += translation;
246 for (
int i = 0; i < 3; i++) {
248 if (std::abs(tshift) >
TOL) {
275 bool was_within(
true);
276 Eigen::Vector3d lattice_trans;
277 while (
home().max_voronoi_measure(
cart(), lattice_trans) > (1. +
TOL)) {
279 cart() -= lattice_trans;
292 assert(
m_home &&
"home lattice pointer was set to null!");
293 translation.
cart() = vector_type::Zero();
295 Eigen::Vector3d lattice_trans;
296 bool was_within(
true);
297 while (
home().max_voronoi_measure(
cart(), lattice_trans) > (1. +
TOL)) {
299 cart() -= lattice_trans;
300 translation.
cart() -= lattice_trans;
349 mutating_coord.
cart() =
351 return mutating_coord;
static COORD_TYPE CHECK()
get the current mode (call using COORD_MODE::CHECK())
Represents cartesian and fractional coordinates.
bool almost_equal(const Coordinate &RHS) const
bool is_within() const
Checks to see if coordinate is in the unit cell, but does not translate it.
const Lattice & home() const
Access the home lattice of the coordinate.
void print(std::ostream &stream, COORD_TYPE mode, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
double min_dist2(const Coordinate &neighbor, const Eigen::Ref< const Eigen::Matrix3d > &metric) const
Coordinate & operator+=(const Coordinate &RHS)
Positive translation of this coordinate by RHS.cart()
Coordinate_impl::CartCoordinate cart()
Set Cartesian coordinate vector and update fractional coordinate vector.
void set_lattice(const Lattice &new_lat, COORD_TYPE mode)
Change the home lattice of the coordinate, selecting one representation (either CART or FRAC) that re...
bool is_lattice_shift(double tol=TOL) const
int voronoi_number() const
const Lattice & lattice() const
Access the home lattice of the coordinate.
void print_axis(std::ostream &stream, COORD_TYPE mode, char term=0, Eigen::IOFormat format=Eigen::IOFormat(7, 12)) const
Print normalized vector.
Eigen::Vector3d vector_type
const vector_type & const_frac() const
user override to force const Access the fractional coordinate vector
bool compare(const Coordinate &RHS) const
Returns true if this->min_dist(RHS)<this->lattice().tol()
Coordinate(const Lattice &_home)
Minimal constructor only takes a lattice.
Coordinate min_translation(const Coordinate &neighbor) const
Returns translation coordinate (in Angstr) to nearest periodic image of neighbor.
double robust_min_dist(const Coordinate &neighbor) const
Returns distance (in Angstr) to nearest periodic image of neighbor.
bool compare_type(const Coordinate &RHS) const
Return true – Exists to allow duck-typing with Site.
bool voronoi_within()
Map coordinate into the voronoi cell using a lattice translation.
bool operator==(const Coordinate &RHS) const
Coordinate & operator-=(const Coordinate &RHS)
Negative translation of this coordinate by RHS.cart()
void read(std::istream &stream, COORD_TYPE mode)
double min_dist(const Coordinate &neighbor) const
Returns distance (in Angstr) to nearest periodic image of neighbor.
Coordinate_impl::FracCoordinate frac()
Set the fractional coordinate vector.
const vector_type & const_cart() const
user override to force const Access the Cartesian coordinate vector
Coordinate operator-() const
unary minus of this coordinate
double dist(const Coordinate &neighbor) const
distance (in Angstr) of neighbor from *this
int voronoi_number(const Eigen::Vector3d &pos) const
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Coordinate operator*(const SymOp &LHS, const Coordinate &RHS)
Eigen::CwiseUnaryOp< decltype(Local::lround_l< typename Derived::Scalar >), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
Eigen::CwiseUnaryOp< decltype(Local::round_l< typename Derived::Scalar >), const Derived > round(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd.
const SymOp::matrix_type & get_matrix(const SymOp &op)
const SymOp::vector_type & get_translation(const SymOp &op)
T dot(const Tensor< T > &LHS, const Tensor< T > &RHS)
xtal::Coordinate copy_apply(const xtal::SymOp &op, xtal::Coordinate coord)
Copy and apply SymOp to a Coordinate.
xtal::Coordinate & apply(const xtal::SymOp &op, xtal::Coordinate &coord)
apply SymOp to a Coordinate
void _formatted_print(std::ostream &stream, Eigen::Vector3d vec, COORD_TYPE mode, char term, Eigen::IOFormat format)
std::ostream & operator<<(std::ostream &stream, const Site &site)
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.