Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## codeanticode.proscene
Class PSFrame

    java.lang.Object
      codeanticode.proscene.PSFrame

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  PSInteractiveFrame

    public class PSFrame

extends java.lang.Object
implements java.lang.Cloneable

A PSFrame is a 3D coordinate system, represented by a `position()` and an `orientation()`. The order of these transformations is important: the PSFrame is first translated and then rotated around the new translated origin.

Constructor Summary
`PSFrame()` Creates a default PSFrame.
`PSFrame(processing.core.PVector p, PSQuaternion r)` Creates a PSFrame with a `position()` and an `orientation()`.

Method Summary
`void` | `alignWithFrame(PSFrame frame)` Convenience function that simply calls `alignWithFrame(frame, false, 0.85f)`
`void` | `alignWithFrame(PSFrame frame, boolean move)` Convenience function that simply calls `alignWithFrame(frame, move, 0.85f)`
`void` | `alignWithFrame(PSFrame frame, boolean move, float threshold)` Aligns the PSFrame with `frame`, so that two of their axis are parallel.
`void` | `alignWithFrame(PSFrame frame, float threshold)` Convenience function that simply calls `alignWithFrame(frame, false, threshold)`
`void` | `applyTransformation(processing.core.PApplet p)` Apply the transformation defined by this PSFrame to `p`.
`PSFrame` | `clone()` Implementation of the clone method.
`PSConstraint` | `constraint()` Returns the current constraint applied to the PSFrame.
`processing.core.PVector` | `coordinatesOf(processing.core.PVector src)` Returns the PSFrame coordinates of a point `src` defined in the world coordinate system (converts from world to Frame).
`processing.core.PVector` | `coordinatesOfFrom(processing.core.PVector src, PSFrame from)` Returns the PSFrame coordinates of the point whose position in the `from` coordinate system is `src` (converts from `from` to PSFrame).
`processing.core.PVector` | `coordinatesOfIn(processing.core.PVector src, PSFrame in)` Returns the `in` coordinates of the point whose position in the PSFrame coordinate system is `src` (converts from PSFrame to `in`).
`PSFrame` | `copy()` Calls `PSFrame(PSFrame)` (which is private) and returns a copy of `this` object.
`void` | `fromMatrix(processing.core.PMatrix3D pM)` Sets the PSFrame from an PMatrix3D (processing matrix) representation (rotation in the upper left 3x3 matrix and translation on the last column).
`PSFrame` | `inverse()` Returns a PSFrame representing the inverse of the PSFrame space transformation.
`processing.core.PVector` | `inverseCoordinatesOf(processing.core.PVector src)` Returns the world coordinates of the point whose position in the PSFrame coordinate system is `src` (converts from Frame to world).
`processing.core.PVector` | `inverseTransformOf(processing.core.PVector src)` Returns the world transform of the vector whose coordinates in the PSFrame coordinate system is `src` (converts vectors from Frame to world).
`processing.core.PVector` | `localCoordinatesOf(processing.core.PVector src)` Returns the PSFrame coordinates of a point `src` defined in the `referenceFrame()` coordinate system (converts from `referenceFrame()` to Frame).
`processing.core.PVector` | `localInverseCoordinatesOf(processing.core.PVector src)` Returns the `referenceFrame()` coordinates of a point `src` defined in the PSFrame coordinate system (converts from Frame to `referenceFrame()`).
`processing.core.PVector` | `localInverseTransformOf(processing.core.PVector src)` Returns the `referenceFrame()` transform of a vector `src` defined in the PSFrame coordinate system (converts vectors from PSFrame to `referenceFrame()`).
`processing.core.PVector` | `localTransformOf(processing.core.PVector src)` Returns the PSFrame transform of a vector `src` defined in the `referenceFrame()` coordinate system (converts vectors from `referenceFrame()` to PSFrame).
`processing.core.PMatrix3D` | `matrix()` Returns the PMatrix3D associated with this PSFrame.
`PSQuaternion` | `orientation()` Returns the orientation of the PSFrame, defined in the world coordinate system.
`processing.core.PVector` | `position()` Returns the position of the PSFrame, defined in the world coordinate system.
`void` | `projectOnLine(processing.core.PVector origin, processing.core.PVector direction)` Translates the PSFrame so that its `position()` lies on the line defined by `origin` and `direction` (defined in the world coordinate system).
`PSFrame` | `referenceFrame()` Returns the reference PSFrame, in which coordinates system the PSFrame is defined.
`void` | `rotate(float x, float y, float z, float w)` Same as `rotate(PSQuaternion)` but with `float` PSQuaternion parameters.
`void` | `rotate(PSQuaternion q)` Rotates the PSFrame by `q` (defined in the PSFrame coordinate system): `R = R*q`.
`void` | `rotateAroundPoint(PSQuaternion rotation, processing.core.PVector point)` Makes the PSFrame `rotate(PSQuaternion)` by `rotation` around `point`.
`void` | `rotateAroundPointModifyingArgument(PSQuaternion rotation, processing.core.PVector point)` Same as `rotateAroundPoint(PSQuaternion, PVector)` but if there's a `constraint()` `rotation` is modified to satisfy it.
`void` | `rotateModifyingArgument(PSQuaternion q)` Same as `rotate(PSQuaternion)` but if there's a `constraint()` `q` is modified to satisfy it.
`PSQuaternion` | `rotation()` Returns the PSFrame rotation, defined with respect to the `referenceFrame()` (i.e, the current PSQuaternion orientation).
`void` | `setConstraint(PSConstraint c)`
`void` | `setOrientation(float x, float y, float z, float w)` Same as `setOrientation(PSQuaternion)`, but with `float` parameters.
`void` | `setOrientation(PSQuaternion q)` Sets the `orientation()` of the PSFrame, defined in the world coordinate system.
`void` | `setOrientationWithConstraint(PSQuaternion orientation)` Same as `setOrientation(PSQuaternion)`, but if there's a `constraint()` it is satisfied (without modifying `orientation`).
`void` | `setPosition(float x, float y, float z)` Same as `setPosition(float, float, float)`, but with `float` parameters.
`void` | `setPosition(processing.core.PVector p)` Sets the `position()` of the PSFrame, defined in the world coordinate system.
`void` | `setPositionWithConstraint(processing.core.PVector position)` Same as `setPosition(PVector)`, but if there's a `constraint()` it is satisfied (without modifying `position`).
`void` | `setReferenceFrame(PSFrame rFrame)` Sets the `referenceFrame()` of the PSFrame.
`void` | `setRotation(float x, float y, float z, float w)` Same as `setRotation(PSQuaternion)` but with `float` PSQuaternion parameters.
`void` | `setRotation(PSQuaternion r)` Set the current rotation PSQuaternion.
`void` | `setRotationWithConstraint(PSQuaternion rotation)` Same as `setRotation(PSQuaternion)`, if there's a `constraint()` it's satisfied (without modifying `rotation`).
`boolean` | `settingAsReferenceFrameWillCreateALoop(PSFrame frame)` Returns `true` if setting `frame` as the PSFrame's `referenceFrame()` would create a loop in the PSFrame hierarchy.
`void` | `setTranslation(float x, float y, float z)` Same as `setTranslation(PVector)`, but with `float` parameters.
`void` | `setTranslation(processing.core.PVector t)` Sets the `translation()` of the frame, locally defined with respect to the `referenceFrame()`.
`void` | `setTranslationWithConstraint(processing.core.PVector translation)` Same as `setTranslation(PVector)`, but if there's a `constraint()` it is satisfied (without modifying `translation`).
`processing.core.PVector` | `transformOf(processing.core.PVector src)` Returns the PSFrame transform of a vector `src` defined in the world coordinate system (converts vectors from world to Frame).
`processing.core.PVector` | `transformOfFrom(processing.core.PVector src, PSFrame from)` Returns the PSFrame transform of the vector whose coordinates in the `from` coordinate system is `src` (converts vectors from `from` to PSFrame).
`processing.core.PVector` | `transformOfIn(processing.core.PVector src, PSFrame in)` Returns the `in` transform of the vector whose coordinates in the PSFrame coordinate system is `src` (converts vectors from PSFrame to `in`).
`void` | `translate(float x, float y, float z)` Same as `translate(PVector)` but with `float` parameters.
`void` | `translate(processing.core.PVector t)` Translates the PSFrame of `t` (defined in the PSFrame coordinate system).
`void` | `translateModifyingArgument(processing.core.PVector t)` Same as `translate(PVector)` but if there's a `constraint()` `t` is modified to satisfy it.
`processing.core.PVector` | `translation()` Returns the PSFrame translation, defined with respect to the `referenceFrame()`.
`PSFrame` | `worldInverse()` Returns the `inverse()` of the PSFrame world transformation.
`processing.core.PMatrix3D` | `worldMatrix()` Returns the processing transformation matrix represented by the PSFrame.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PSFrame

    public PSFrame()

  Creates a default PSFrame.

  Its `position()` is (0,0,0) and it has an identity `orientation()` PSQuaternion. The `referenceFrame()` and the `constraint()` are `null`.

### PSFrame

    public PSFrame(processing.core.PVector p,
                   PSQuaternion r)

  Creates a PSFrame with a `position()` and an `orientation()`.

  See the PVector and PSQuaternion documentations for convenient constructors and methods.

  The PSFrame is defined in the world coordinate system (its `referenceFrame()` is `null`). It has a `null` associated `constraint()`.

Method Detail

### copy

    public PSFrame copy()

  Calls `PSFrame(PSFrame)` (which is private) and returns a copy of `this` object.

  See Also:
    `PSFrame(PSFrame)`

### clone

    public PSFrame clone()

  Implementation of the clone method.

  The method performs a deep copy of the `translation()` and `rotation()` objects of the PSFrame, and a shallow copy of its `referenceFrame()` and `constraint()` objects.

  Overrides:
    `clone` in class `java.lang.Object`
  See Also:
    `copy()`

### translation

    public final processing.core.PVector translation()

  Returns the PSFrame translation, defined with respect to the `referenceFrame()`.

  Use `position()` to get the result in the world coordinates. These two values are identical when the `referenceFrame()` is `null` (default).

  See Also:
    `setTranslation(PVector)`, `setTranslationWithConstraint(PVector)`

### rotation

    public final PSQuaternion rotation()

  Returns the PSFrame rotation, defined with respect to the `referenceFrame()` (i.e, the current PSQuaternion orientation).

  Use `orientation()` to get the result in the world coordinates. These two values are identical when the `referenceFrame()` is `null` (default).

  See Also:
    `setRotation(PSQuaternion)`, `setRotationWithConstraint(PSQuaternion)`

### referenceFrame

    public final PSFrame referenceFrame()

  Returns the reference PSFrame, in which coordinates system the PSFrame is defined.

  The `translation()` `rotation()` of the PSFrame are defined with respect to the reference PSFrame coordinate system. A `null` reference PSFrame (default value) means that the PSFrame is defined in the world coordinate system.

  Use `position()` and `orientation()` to recursively convert values along the reference PSFrame chain and to get values expressed in the world coordinate system. The values match when the reference PSFrame `null`.

  Use `setReferenceFrame(PSFrame)` to set this value and create a Frame hierarchy. Convenient functions allow you to convert 3D coordinates from one PSFrame to another: see `coordinatesOf(PVector)`, `localCoordinatesOf(PVector)` , `coordinatesOfIn(PVector, PSFrame)` and their inverse functions.

  Vectors can also be converted using `transformOf(PVector)`, `transformOfIn(PVector, PSFrame)`, `localTransformOf(PVector)` and their inverse functions.

### constraint

    public PSConstraint constraint()

  Returns the current constraint applied to the PSFrame.

  A `null` value (default) means that no PSConstraint is used to filter the PSFrame translation and rotation.

  See the PSConstraint class documentation for details.

### setTranslation

    public final void setTranslation(processing.core.PVector t)

  Sets the `translation()` of the frame, locally defined with respect to the `referenceFrame()`.

  Use `setPosition(PVector)` to define the world coordinates `position()`. Use `setTranslationWithConstraint(PVector)` to take into account the potential `constraint()` of the PSFrame.

### setTranslation

    public final void setTranslation(float x,
                                     float y,
                                     float z)

  Same as `setTranslation(PVector)`, but with `float` parameters.

### setTranslationWithConstraint

    public final void setTranslationWithConstraint(processing.core.PVector translation)

  Same as `setTranslation(PVector)`, but if there's a `constraint()` it is satisfied (without modifying `translation`).

  See Also:
    `setRotationWithConstraint(PSQuaternion)`, `setPositionWithConstraint(PVector)`

### setRotation

    public final void setRotation(PSQuaternion r)

  Set the current rotation PSQuaternion. See the different PSQuaternion constructors.

  Sets the `rotation()` of the Frame, locally defined with respect to the `referenceFrame()`.

  Use `setOrientation(PSQuaternion)` to define the world coordinates `orientation()`. The potential `constraint()` of the PSFrame is not taken into account, use `setRotationWithConstraint(PSQuaternion)` instead.

  See Also:
    `setRotationWithConstraint(PSQuaternion)`, `rotation()`, `setTranslation(PVector)`

### setRotation

    public final void setRotation(float x,
                                  float y,
                                  float z,
                                  float w)

  Same as `setRotation(PSQuaternion)` but with `float` PSQuaternion parameters.

### setRotationWithConstraint

    public final void setRotationWithConstraint(PSQuaternion rotation)

  Same as `setRotation(PSQuaternion)`, if there's a `constraint()` it's satisfied (without modifying `rotation`).

  See Also:
    `setTranslationWithConstraint(PVector)`, `setOrientationWithConstraint(PSQuaternion)`

### setReferenceFrame

    public final void setReferenceFrame(PSFrame rFrame)

  Sets the `referenceFrame()` of the PSFrame.

  The PSFrame `translation()` and `rotation()` are then defined in the `referenceFrame()` coordinate system.

  Use `position()` and `orientation()` to express these in the world coordinate system.

  Using this method, you can create a hierarchy of Frames. This hierarchy needs to be a tree, which root is the world coordinate system (i.e., `null` `referenceFrame()`). No action is performed if setting `refFrame` as the `referenceFrame()` would create a loop in the PSFrame hierarchy.

  See Also:
    `settingAsReferenceFrameWillCreateALoop(PSFrame)`

### setConstraint

    public void setConstraint(PSConstraint c)

### settingAsReferenceFrameWillCreateALoop

    public final boolean settingAsReferenceFrameWillCreateALoop(PSFrame frame)

  Returns `true` if setting `frame` as the PSFrame's `referenceFrame()` would create a loop in the PSFrame hierarchy.

### orientation

    public final PSQuaternion orientation()

  Returns the orientation of the PSFrame, defined in the world coordinate system.

  See Also:
    `position()`, `setOrientation(PSQuaternion)`, `rotation()`

### setPosition

    public final void setPosition(processing.core.PVector p)

  Sets the `position()` of the PSFrame, defined in the world coordinate system.

  Use `setTranslation(PVector)` to define the local PSframe translation (with respect to the `referenceFrame()`). The potential `constraint()` of the PSFrame is not taken into account, use `setPositionWithConstraint(PVector)` instead.

### setPosition

    public final void setPosition(float x,
                                  float y,
                                  float z)

  Same as `setPosition(float, float, float)`, but with `float` parameters.

### setPositionWithConstraint

    public final void setPositionWithConstraint(processing.core.PVector position)

  Same as `setPosition(PVector)`, but if there's a `constraint()` it is satisfied (without modifying `position`).

  See Also:
    `setOrientationWithConstraint(PSQuaternion)`, `setTranslationWithConstraint(PVector)`

### setOrientation

    public final void setOrientation(PSQuaternion q)

  Sets the `orientation()` of the PSFrame, defined in the world coordinate system.

  Use `setRotation(PSQuaternion)`to define the local frame rotation (with respect to the `referenceFrame()`). The potential `constraint()` of the PSFrame is not taken into account, use `setOrientationWithConstraint(PSQuaternion)` instead.

### setOrientation

    public final void setOrientation(float x,
                                     float y,
                                     float z,
                                     float w)

  Same as `setOrientation(PSQuaternion)`, but with `float` parameters.

### setOrientationWithConstraint

    public final void setOrientationWithConstraint(PSQuaternion orientation)

  Same as `setOrientation(PSQuaternion)`, but if there's a `constraint()` it is satisfied (without modifying `orientation`).

  See Also:
    `setPositionWithConstraint(PVector)`, `setRotationWithConstraint(PSQuaternion)`

### position

    public final processing.core.PVector position()

  Returns the position of the PSFrame, defined in the world coordinate system.

  See Also:
    `orientation()`, `setPosition(PVector)`, `translation()`

### translate

    public final void translate(processing.core.PVector t)

  Translates the PSFrame of `t` (defined in the PSFrame coordinate system).

  If there's a `constraint()` it is satisfied without modifying `t`: The translation actually applied to the PSFrame may differ from `t` since it can be filtered by the `constraint()`. Use `translateModifyingArgument(PVector)` to retrieve the filtered translation value. Use `setTranslation(PVector)` to directly translate the PSFrame without taking the `constraint()` into account.

  See Also:
    `rotate(PSQuaternion)`

### translateModifyingArgument

    public final void translateModifyingArgument(processing.core.PVector t)

  Same as `translate(PVector)` but if there's a `constraint()` `t` is modified to satisfy it.

### translate

    public final void translate(float x,
                                float y,
                                float z)

  Same as `translate(PVector)` but with `float` parameters.

### rotate

    public final void rotate(PSQuaternion q)

  Rotates the PSFrame by `q` (defined in the PSFrame coordinate system): `R = R*q`.

  If there's a `constraint()` it is satisfied without modifying `q`: The rotation actually applied to the PSFrame may differ from `q` since it can be filtered by the `constraint()`. Use `rotateModifyingArgument(PSQuaternion)` to retrieve the filtered rotation value. Use `setRotation(PSQuaternion)` to directly rotate the PSFrame without taking the `constraint()` into account.

  See Also:
    `translate(PVector)`

### rotateModifyingArgument

    public final void rotateModifyingArgument(PSQuaternion q)

  Same as `rotate(PSQuaternion)` but if there's a `constraint()` `q` is modified to satisfy it.

### rotate

    public final void rotate(float x,
                             float y,
                             float z,
                             float w)

  Same as `rotate(PSQuaternion)` but with `float` PSQuaternion parameters.

### rotateAroundPoint

    public final void rotateAroundPoint(PSQuaternion rotation,
                                        processing.core.PVector point)

  Makes the PSFrame `rotate(PSQuaternion)` by `rotation` around `point`.

  `point` is defined in the world coordinate system, while the `rotation` axis is defined in the PSFrame coordinate system.

  If the PSFrame has a `constraint()`, `rotation` is first constrained using `proscene.PSConstraint#constrainRotation(PSQuaternion, PSFrame)`. The translation which results from the filtered rotation around `point` is then computed and filtered using `proscene.PSConstraint#constrainTranslation(PVector, PSFrame)`.

### rotateAroundPointModifyingArgument

    public final void rotateAroundPointModifyingArgument(PSQuaternion rotation,
                                                         processing.core.PVector point)

  Same as `rotateAroundPoint(PSQuaternion, PVector)` but if there's a `constraint()` `rotation` is modified to satisfy it.

### alignWithFrame

    public final void alignWithFrame(PSFrame frame)

  Convenience function that simply calls `alignWithFrame(frame, false, 0.85f)`

### alignWithFrame

    public final void alignWithFrame(PSFrame frame,
                                     boolean move)

  Convenience function that simply calls `alignWithFrame(frame, move, 0.85f)`

### alignWithFrame

    public final void alignWithFrame(PSFrame frame,
                                     float threshold)

  Convenience function that simply calls `alignWithFrame(frame, false, threshold)`

### alignWithFrame

    public final void alignWithFrame(PSFrame frame,
                                     boolean move,
                                     float threshold)

  Aligns the PSFrame with `frame`, so that two of their axis are parallel.

  If one of the X, Y and Z axis of the PSFrame is almost parallel to any of the X, Y, or Z axis of `frame`, the PSFrame is rotated so that these two axis actually become parallel.

  If, after this first rotation, two other axis are also almost parallel, a second alignment is performed. The two frames then have identical orientations, up to 90 degrees rotations.

  `threshold` measures how close two axis must be to be considered parallel. It is compared with the absolute values of the dot product of the normalized axis.

  When `move` is set to `true`, the PSFrame `position()` is also affected by the alignment. The new PSFrame `position()` is such that the `frame` frame position (computed with `coordinatesOf(PVector)`, in the PSFrame coordinates system) does not change.

  `frame` may be `null` and then represents the world coordinate system (same convention than for the `referenceFrame()`).

### projectOnLine

    public final void projectOnLine(processing.core.PVector origin,
                                    processing.core.PVector direction)

  Translates the PSFrame so that its `position()` lies on the line defined by `origin` and `direction` (defined in the world coordinate system).

  Simply uses an orthogonal projection. `direction` does not need to be normalized.

### coordinatesOf

    public final processing.core.PVector coordinatesOf(processing.core.PVector src)

  Returns the PSFrame coordinates of a point `src` defined in the world coordinate system (converts from world to Frame).

  `inverseCoordinatesOf(PVector)` performs the inverse conversion. `transformOf(PVector)` converts 3D vectors instead of 3D coordinates.

### inverseCoordinatesOf

    public final processing.core.PVector inverseCoordinatesOf(processing.core.PVector src)

  Returns the world coordinates of the point whose position in the PSFrame coordinate system is `src` (converts from Frame to world).

  `coordinatesOf(PVector)` performs the inverse conversion. Use `inverseTransformOf(PVector)` to transform 3D vectors instead of 3D coordinates.

### localCoordinatesOf

    public final processing.core.PVector localCoordinatesOf(processing.core.PVector src)

  Returns the PSFrame coordinates of a point `src` defined in the `referenceFrame()` coordinate system (converts from `referenceFrame()` to Frame).

  `localInverseCoordinatesOf(PVector)` performs the inverse conversion.

  See Also:
    `localTransformOf(PVector)`

### localInverseCoordinatesOf

    public final processing.core.PVector localInverseCoordinatesOf(processing.core.PVector src)

  Returns the `referenceFrame()` coordinates of a point `src` defined in the PSFrame coordinate system (converts from Frame to `referenceFrame()`).

  `localCoordinatesOf(PVector)` performs the inverse conversion.

  See Also:
    `localInverseTransformOf(PVector)`

### coordinatesOfFrom

    public final processing.core.PVector coordinatesOfFrom(processing.core.PVector src,
                                                           PSFrame from)

  Returns the PSFrame coordinates of the point whose position in the `from` coordinate system is `src` (converts from `from` to PSFrame).

  `coordinatesOfIn(PVector, PSFrame)` performs the inverse transformation.

### coordinatesOfIn

    public final processing.core.PVector coordinatesOfIn(processing.core.PVector src,
                                                         PSFrame in)

  Returns the `in` coordinates of the point whose position in the PSFrame coordinate system is `src` (converts from PSFrame to `in`).

  `coordinatesOfFrom(PVector, PSFrame)` performs the inverse transformation.

### transformOf

    public final processing.core.PVector transformOf(processing.core.PVector src)

  Returns the PSFrame transform of a vector `src` defined in the world coordinate system (converts vectors from world to Frame).

  `inverseTransformOf(PVector)` performs the inverse transformation. `coordinatesOf(PVector)` converts 3D coordinates instead of 3D vectors (here only the rotational part of the transformation is taken into account).

### inverseTransformOf

    public final processing.core.PVector inverseTransformOf(processing.core.PVector src)

  Returns the world transform of the vector whose coordinates in the PSFrame coordinate system is `src` (converts vectors from Frame to world).

  `transformOf(PVector)` performs the inverse transformation. Use `inverseCoordinatesOf(PVector)` to transform 3D coordinates instead of 3D vectors.

### localTransformOf

    public final processing.core.PVector localTransformOf(processing.core.PVector src)

  Returns the PSFrame transform of a vector `src` defined in the `referenceFrame()` coordinate system (converts vectors from `referenceFrame()` to PSFrame).

  `localInverseTransformOf(PVector)` performs the inverse transformation.

  See Also:
    `localCoordinatesOf(PVector)`

### localInverseTransformOf

    public final processing.core.PVector localInverseTransformOf(processing.core.PVector src)

  Returns the `referenceFrame()` transform of a vector `src` defined in the PSFrame coordinate system (converts vectors from PSFrame to `referenceFrame()`).

  `localTransformOf(PVector)` performs the inverse transformation.

  See Also:
    `localInverseCoordinatesOf(PVector)`

### transformOfFrom

    public final processing.core.PVector transformOfFrom(processing.core.PVector src,
                                                         PSFrame from)

  Returns the PSFrame transform of the vector whose coordinates in the `from` coordinate system is `src` (converts vectors from `from` to PSFrame).

  `transformOfIn(PVector, PSFrame)` performs the inverse transformation.

### transformOfIn

    public final processing.core.PVector transformOfIn(processing.core.PVector src,
                                                       PSFrame in)

  Returns the `in` transform of the vector whose coordinates in the PSFrame coordinate system is `src` (converts vectors from PSFrame to `in`).

  `transformOfFrom(PVector, PSFrame)` performs the inverse transformation.

### matrix

    public final processing.core.PMatrix3D matrix()

  Returns the PMatrix3D associated with this PSFrame.

  This method should be used in conjunction with `applyMatrix()` to modify the processing modelview matrix from a PSFrame hierarchy. For example with this PSFrame hierarchy:

  `PSFrame body = new PSFrame();`
  `PSFrame leftArm = new PSFrame();`
  `PSFrame rightArm = new PSFrame();`
  `leftArm.setReferenceFrame(body);`
  `rightArm.setReferenceFrame(body);`

  The associated processing drawing code should look like:

  `pushMatrix();`
  `applyMatrix(body.matrix());`
  `drawBody();`
  `pushMatrix();`
  `applyMatrix(leftArm.matrix());`
  `drawArm();`
  `popMatrix();`
  `pushMatrix();`
  `applyMatrix(rightArm.matrix());`
  `drawArm();`
  `popMatrix();`
  `popMatrix();`

  Note the use of nested `pushMatrix()` and `popMatrix()` blocks to represent the frame hierarchy: `leftArm` and `rightArm` are both correctly drawn with respect to the `body` coordinate system.

  This matrix only represents the local PSFrame transformation (i.e., with respect to the `referenceFrame()`). Use `worldMatrix()` to get the full PSFrame transformation matrix (i.e., from the world to the Frame coordinate system). These two match when the `referenceFrame()` is `null`.

  The result is only valid until the next call to `matrix()` or `worldMatrix()`. Use it immediately (as above).

  Note: The scaling factor of the 4x4 matrix is 1.0.

### applyTransformation

    public void applyTransformation(processing.core.PApplet p)

  Apply the transformation defined by this PSFrame to `p`. The PSFrame is first translated and then rotated around the new translated origin.

  Same as:

  `p.translate(translation().x, translation().y, translation().z);`
  `p.rotate(rotation().angle(), rotation().axis().x, rotation().axis().y, rotation().axis().z);`

  This method should be used whenever possible.

  Attention: In order to apply the PSFrame transformation one can also call `p.applyMatrix(this.pMatrix())`. However, `p.applyMatrix` is very slow because it will try to calculate the inverse of the transform, so it should be avoided whenever possible.

### worldMatrix

    public final processing.core.PMatrix3D worldMatrix()

  Returns the processing transformation matrix represented by the PSFrame.

  This method should be used in conjunction with `applyMatrix()` to modify the processing modelview matrix from a PSFrame:

  `// The modelview here corresponds to the world coordinate system.` `PSFrame fr = new PSFrame(pos, PSQuaternion(from, to));`
  `pushMatrix();`
  `applyMatrix(worldMatrix());`
  `// draw object in the fr coordinate system.`
  `popMatrix();`

  This matrix represents the global PSFrame transformation: the entire `referenceFrame()` hierarchy is taken into account to define the PSFrame transformation from the world coordinate system. Use `matrix()` to get the local PSFrame transformation matrix (i.e. defined with respect to the referenceFrame()). These two match when the `referenceFrame()` is `null`.

  Attention: The result is only valid until the next call to `matrix()` or `worldMatrix()`. Use it immediately (as above).

  Note: The scaling factor of the 4x4 matrix is 1.0.

### fromMatrix

    public final void fromMatrix(processing.core.PMatrix3D pM)

  Sets the PSFrame from an PMatrix3D (processing matrix) representation (rotation in the upper left 3x3 matrix and translation on the last column).

  Hence, if a code fragment looks like:

  `float [] m = new float [16]; m[0]=...;`
  `gl.glMultMatrixf(m);`

  It is equivalent to write:

  `PSFrame fr = new PSFrame();`
  `fr.fromMatrix(m);`
  `applyMatrix(fr.matrix());`

  Using this conversion, you can benefit from the powerful PSFrame transformation methods to translate points and vectors to and from the PSFrame coordinate system to any other PSFrame coordinate system (including the world coordinate system). See `coordinatesOf(PVector)` and `transformOf(PVector)`.

  Attention: A PSFrame does not contain a scale factor. The possible scaling in `m` will not be converted into the PSFrame by this method.

### inverse

    public final PSFrame inverse()

  Returns a PSFrame representing the inverse of the PSFrame space transformation.

  The `rotation()` the new PSFrame is the `proscene.PSQuaternion#inverse()` of the original rotation. Its `translation()` is the negated inverse rotated image of the original translation.

  If a PSFrame is considered as a space rigid transformation (translation and rotation), the inverse() PSFrame performs the inverse transformation.

  Only the local PSFrame transformation (i.e., defined with respect to the `referenceFrame()`) is inverted. Use `worldInverse()` for a global inverse.

  The resulting PSFrame has the same `referenceFrame()` as the PSFrame and a `null` `constraint()`.

  Note: The scaling factor of the 4x4 matrix is 1.0.

### worldInverse

    public final PSFrame worldInverse()

  Returns the `inverse()` of the PSFrame world transformation.

  The `orientation()` of the new PSFrame is the `proscene.PSQuaternion#inverse()` of the original orientation. Its `position()` is the negated and inverse rotated image of the original position.

  The result PSFrame has a `null` `referenceFrame()` and a `null` `constraint()`.

  Use `inverse()` for a local (i.e., with respect to `referenceFrame()`) transformation inverse.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

processing library glgraphics by Andres Colubri. (c) 2008