pose_format.torch.representation.inner_angle module

Classes:

InnerAngleRepresentation(*args, **kwargs)

A neural network module to compute the inner angle at a point for a triangle.

Functions:

get_vectors_norm(vectors)

Computes the normalized vectors from the given masked vectors.

class pose_format.torch.representation.inner_angle.InnerAngleRepresentation(*args, **kwargs)[source]

Bases: Module

A neural network module to compute the inner angle at a point for a triangle.

Methods:

forward(p1s, p2s, p3s)

Computes the angle in point p2s for the triangle defined by the points <p1s, p2s, p3s>.

Attributes:

training

forward(p1s, p2s, p3s)[source]

Computes the angle in point p2s for the triangle defined by the points <p1s, p2s, p3s>.

Parameters:
  • p1s (MaskedTensor) – A tensor representing the first set of points, with shape (Points, Batch, Len, Dims).

  • p2s (MaskedTensor) – A tensor representing the second set of points (at which the angle is calculated), with shape (Points, Batch, Len, Dims).

  • p3s (MaskedTensor) – A tensor representing the third set of points, with shape (Points, Batch, Len, Dims).

Returns:

A tensor representing the computed angles at point p2s, with shape (Points, Batch, Len).

Return type:

torch.Tensor

Note

The method is based on the approach suggested in: https://stackoverflow.com/questions/19729831/angle-between-3-points-in-3d-space

The function first computes the vectors v1 and v2 by subtracting points p1s and p3s from p2s, respectively. The vectors are then normalized. The angle is calculated by finding the arccosine of the dot product of the normalized vectors. NaN values in the resulting tensor are set to zero.

training: bool
pose_format.torch.representation.inner_angle.get_vectors_norm(vectors)[source]

Computes the normalized vectors from the given masked vectors.

Parameters:

vectors (MaskedTensor) – The input masked vectors with any shape.

Returns:

The normalized masked vectors of the same shape as the input.

Return type:

MaskedTensor

Notes

The function squares the input vectors, then sums along the last dimension. Taking the square root of the sum provides the magnitude. The original vectors are then divided by this magnitude to normalize.