# LocalCoordinatesSite¶

class OpenMM::LocalCoordinatesSite

This is a VirtualSite that uses the locations of several other particles to compute a local coordinate system, then places the virtual site at a fixed location in that coordinate system. The origin of the coordinate system and the directions of its x and y axes are each specified as a weighted sum of the locations of the other particles:

origin = w1 r1 + w2 r2 + w3 r3 + ...

xdir = w1 r1 + w2 r2 + w3 r3 + ...

ydir = w1 r1 + w2 r2 + w3 r3 + ...

For the origin, the weights must add to one. For example if (w1 , w2 , w3 ) = (1.0, 0.0, 0.0), the origin of the local coordinate system is at the location of particle 1. For xdir and ydir, the weights must add to zero. For example, if (w1 , w2 , w3 ) = (-1.0, 0.5, 0.5), the x axis points from particle 1 toward the midpoint between particles 2 and 3.

The z direction is computed as zdir = xdir x ydir. To ensure the axes are all orthogonal, ydir is then recomputed as ydir = zdir x xdir. All three axis vectors are then normalized, and the virtual site location is set to

origin + x*xdir + y*ydir + z*zdir

Methods

 LocalCoordinatesSite Create a new LocalCoordinatesSite virtual site. LocalCoordinatesSite Create a new LocalCoordinatesSite virtual site. getOriginWeights Get the weight factors for the particles when computing the origin location. getOriginWeights Get the weight factors for the particles when computing the origin location. getXWeights Get the weight factors for the particles when computing xdir. getXWeights Get the weight factors for the particles when computing xdir. getYWeights Get the weight factors for the particles when computing ydir. getYWeights Get the weight factors for the particles when computing ydir. getLocalPosition Get the position of the virtual site in the local coordinate system.
LocalCoordinatesSite(const std::vector<int> &particles, const std::vector<double> &originWeights, const std::vector<double> &xWeights, const std::vector<double> &yWeights, const Vec3 &localPosition)

Create a new LocalCoordinatesSite() virtual site.

• particles – the indices of the particle the site depends on
• originWeights – the weight factors for the particles when computing the origin location
• xWeights – the weight factors for the particles when computing xdir
• yWeights – the weight factors for the particles when computing ydir
• localPosition – the position of the virtual site in the local coordinate system
LocalCoordinatesSite(int particle1, int particle2, int particle3, const Vec3 &originWeights, const Vec3 &xWeights, const Vec3 &yWeights, const Vec3 &localPosition)

Create a new LocalCoordinatesSite() virtual site. This constructor assumes the site depends on exactly three other particles.

• particle1 – the index of the first particle
• particle2 – the index of the second particle
• particle3 – the index of the third particle
• originWeights – the weight factors for the three particles when computing the origin location
• xWeights – the weight factors for the three particles when computing xdir
• yWeights – the weight factors for the three particles when computing ydir
• localPosition – the position of the virtual site in the local coordinate system
void getOriginWeights(std::vector<double> &weights) const

Get the weight factors for the particles when computing the origin location.

Vec3 getOriginWeights() const

Get the weight factors for the particles when computing the origin location. This version assumes the site depends on exactly three other particles, and throws an exception if that is not the case.

void getXWeights(std::vector<double> &weights) const

Get the weight factors for the particles when computing xdir.

Vec3 getXWeights() const

Get the weight factors for the particles when computing xdir. This version assumes the site depends on exactly three other particles, and throws an exception if that is not the case.

void getYWeights(std::vector<double> &weights) const

Get the weight factors for the particles when computing ydir.

Vec3 getYWeights() const

Get the weight factors for the particles when computing ydir. This version assumes the site depends on exactly three other particles, and throws an exception if that is not the case.

const Vec3 &getLocalPosition() const

Get the position of the virtual site in the local coordinate system.