All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rcs.posemath.PmPose Maven / Gradle / Ivy

Go to download

NIST Real-Time Control Systems Library including Posemath, NML communications and Java Plotter

The newest version!
/* 
The NIST RCS (Real-time Control Systems) 
 library is public domain software, however it is preferred
 that the following disclaimers be attached.

Software Copywrite/Warranty Disclaimer

   This software was developed at the National Institute of Standards and
Technology by employees of the Federal Government in the course of their
official duties. Pursuant to title 17 Section 105 of the United States
Code this software is not subject to copyright protection and is in the
public domain. NIST Real-Time Control System software is an experimental
system. NIST assumes no responsibility whatsoever for its use by other
parties, and makes no guarantees, expressed or implied, about its
quality, reliability, or any other characteristic. We would appreciate
acknowledgement if the software is used. This software can be
redistributed and/or modified freely provided that any derivative works
bear some notice that they are derived from it, and any modified
versions bear some notice that they have been modified.



*/ 

/*
*       New Java File starts here.
*       This file should be named PmPose.java
*/


// Set Package Name
package rcs.posemath;

// Import all NML, CMS, and RCS classes and interfaces
import rcs.nml.NMLFormatConverter;

/*
*       Class definition for PmPose
*       Automatically generated by RCS Java Diagnostics Tool.
*       on Wed Jan 07 10:53:47 EST 1998
*/
public class PmPose implements Cloneable
{
  public PmCartesian tran = new PmCartesian();
  public PmQuaternion rot = new PmQuaternion();

  public void update(NMLFormatConverter nml_fc)
  {
      nml_fc.beginClass("PmPose",null);
      nml_fc.beginClassVar("tran");
      tran.update(nml_fc);
      nml_fc.endClassVar("tran");
      nml_fc.beginClassVar("rot");
      rot.update(nml_fc);
      nml_fc.endClassVar("rot");
      nml_fc.endClass("PmPose",null);
  }

  public PmPose()
  {
  }

  public PmPose(PmCartesian starttran, PmQuaternion startrot)
  {
    tran = starttran;
    rot = startrot;
  }

  public PmPose(PmCartesian starttran, PmRpy startrpy) throws PmException
  {
    tran = starttran;
    Posemath.pmRpyQuatConvert(startrpy,rot);
  }

  public PmPose(PmHomogeneous hom) throws PmException
  {
    tran = hom.tran;
    Posemath.pmMatQuatConvert(hom.rot,rot);
  }

  public PmPose(double dd[][]) throws PmException
  {
    this(new PmHomogeneous(dd));
  }

  public PmPose(
                     double tranx, double trany, double tranz,
                     double rots, double rotx, double roty, double rotz) throws PmException
  {
    tran = new PmCartesian(tranx, trany, tranz);
    rot = new PmQuaternion(rots, rotx, roty, rotz);
  }

  public String toString()
  {
    return " { \n\ttran = "+tran+",\n\trot ="+rot+"\n } ";
  }

  public boolean equals(PmPose p) throws PmException
  {
    if(p == null)
      {
        return false;
      }
    return Posemath.pmPosePoseCompare(p,this);
  }

 public boolean equals(PmHomogeneous h) throws PmException
  {
    if(h == null)
      {
        return false;
      }
    PmPose p = new PmPose();
    Posemath.pmHomPoseConvert(h,p);
    return Posemath.pmPosePoseCompare(p,this);
  }
 
    @Override
    public PmPose clone() {
        PmPose cloned_object = null;
        try {
        cloned_object = (PmPose) super.clone();
        cloned_object.tran = (PmCartesian) this.tran.clone();
        cloned_object.rot = (PmQuaternion) this.rot.clone();

        }  catch (Exception e) {
            e.printStackTrace();
        }
        return cloned_object;
    }

    public float [] toMatFloatArrayTranspose() throws PmException {
        PmHomogeneous hom = new PmHomogeneous();
        Posemath.pmPoseHomConvert(this, hom);
        if(!Posemath.pmMatIsNorm(hom.rot)) {
           throw new PmException(Posemath.PM_NORM_ERR,"hom.rot = "+hom.rot);
        }
        return hom.toMatfTranspose();
    }

    public double [][] toMatdd() throws PmException {
        PmHomogeneous hom = new PmHomogeneous();
        Posemath.pmPoseHomConvert(this, hom);
        if(!Posemath.pmMatIsNorm(hom.rot)) {
           throw new PmException(Posemath.PM_NORM_ERR,"hom.rot = "+hom.rot);
        }
        return hom.toMatdd();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy