Skip to content

Commit

Permalink
AffineTransform3D: add translation defined from a point
Browse files Browse the repository at this point in the history
  • Loading branch information
dlegland committed Jun 7, 2022
1 parent edae317 commit e2e3198
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/main/java/net/ijt/geom3d/AffineTransform3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,32 @@ public interface AffineTransform3D extends Transform3D
// ===================================================================
// static methods

/**
* Creates a translation by the given vector.
*
* @param vect
* the vector of the translation transform
* @return a new instance of AffineTransform3D representing a translation
*/
public static AffineTransform3D createTranslation(Vector3D vect)
{
return new DefaultAffineTransform3D(1, 0, 0, vect.getX(), 0, 1, 0, vect.getY(), 0, 0, 1, vect.getZ());
}
/**
* Creates a translation by the given vector.
*
* @param vect
* the vector of the translation transform
* @return a new instance of AffineTransform3D representing a translation
*/
public static AffineTransform3D createTranslation(Vector3D vect)
{
return createTranslation(vect.getX(), vect.getY(), vect.getZ());
}

/**
* Creates the translation that moves the origin onto the specified point.
*
* @param pos
* the point that will specify the transformation.
* @return a new instance of AffineTransform3D representing a translation
*/
public static AffineTransform3D createTranslation(Point3D pos)
{
return createTranslation(pos.getX(), pos.getY(), pos.getZ());
}

/**
* Creates a translation by the given vector.
* Creates a translation by the given vector specified with its components.
*
* @param dx
* the x-component of the translation transform
Expand Down

0 comments on commit e2e3198

Please sign in to comment.