Commit a175aeba authored by Peter Eastman's avatar Peter Eastman
Browse files

Added division operator to Vec3 and RealVec

parent 65caf22b
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2013 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -126,6 +126,21 @@ public:
data[2] *= rhs;
return *this;
}
// scalar division
Vec3 operator/(double rhs) const {
const Vec3& lhs = *this;
double scale = 1.0/rhs;
return Vec3(lhs[0]*scale, lhs[1]*scale, lhs[2]*scale);
}
Vec3& operator/=(double rhs) {
double scale = 1.0/rhs;
data[0] *= scale;
data[1] *= scale;
data[2] *= scale;
return *this;
}
// dot product
double dot(const Vec3& rhs) const {
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2010 Stanford University and the Authors. *
* Portions copyright (c) 2008-2013 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -136,6 +136,21 @@ public:
return *this;
}
// scalar division
RealVec operator/(double rhs) const {
const RealVec& lhs = *this;
double scale = 1.0/rhs;
return RealVec(lhs[0]*scale, lhs[1]*scale, lhs[2]*scale);
}
RealVec& operator/=(double rhs) {
double scale = 1.0/rhs;
data[0] *= scale;
data[1] *= scale;
data[2] *= scale;
return *this;
}
// dot product
RealOpenMM dot(const RealVec& rhs) const {
const RealVec& lhs = *this;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment