Package net.lenkaspace.creeper.vo

Examples of net.lenkaspace.creeper.vo.CRVector3d


         
          //-- create reference to report controller and register self with it
          reportController = new CRReportController(this);
         
          //-- create basic world and set it to renderer
          world = new CRWorld(0, new CRVector3d(700,650,0), this);
          if (renderer != null) {
            renderer.setWorld(world);
          }
         
          if (!consoleOnly) {
View Full Code Here


   */
  public CRBaseSituatedModel(int id_, CRVector3d position_, CRVector3d size_, double rotation_, SHAPE shape_, String imageFileName_) {
    super(id_);   
    imageFileName = imageFileName_;
    rotation = rotation_;
    position = new CRVector3d(position_);
    previousPosition = CRVector3d.invalidVector();
    size = new CRVector3d(size_);
    isVisible = true;
    shape = shape_;
    alpha = 1.0;
   
    binIndex = -1;
View Full Code Here

  public CRVector3d[] getCorners() {
    if (shape == SHAPE.RECTANGLE) {
      CRVector3d[] corners = new CRVector3d[4];
     
      //-- top right
      corners[0] new CRVector3d(position.x + size.x/2, position.y - size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[0]);
     
      //-- bottom right
      corners[1] new CRVector3d(position.x + size.x/2, position.y + size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[1]);
     
      //-- bottom left
      corners[2] new CRVector3d(position.x - size.x/2, position.y + size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[2]);
     
      //-- top left
      corners[3] new CRVector3d(position.x - size.x/2, position.y - size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[3]);
   
      return corners;
    } else if (shape == SHAPE.CIRCLE) {
      //-- approximate as octagon
      CRVector3d[] corners = new CRVector3d[4];
     
      //-- top right
      corners[0] new CRVector3d(position.x + size.x/2, position.y - size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[0]);
     
      //-- bottom right
      corners[1] new CRVector3d(position.x + size.x/2, position.y + size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[1]);
     
      //-- bottom left
      corners[2] new CRVector3d(position.x - size.x/2, position.y + size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[2]);
     
      //-- top left
      corners[3] new CRVector3d(position.x - size.x/2, position.y - size.y/2, 0);
      rotateVectorInLocalCoordinates(corners[3]);
     
      return corners;
     
    } else {
View Full Code Here

  /**
   * Rotate a vector around own middle
   * @param vector_ CRVector3d vector to rotate
   */
  public void rotateVectorInLocalCoordinates(CRVector3d vector_) {
    CRVector3d temp = new CRVector3d();
    double xDiff = position.x - vector_.x;
    double yDiff = position.y - vector_.y;
    temp.x = position.x - xDiff*Math.cos(Math.toRadians(rotation)) - yDiff*Math.sin(Math.toRadians(rotation));
    temp.y = position.y - xDiff*Math.sin(Math.toRadians(rotation)) + yDiff*Math.cos(Math.toRadians(rotation));
    vector_.copyFrom(temp);
 
View Full Code Here

   * @param vector_ CRVector3d vector to point towards
   * @param pivot_ CRVector3d vector (within own body) to measure from.
   * @return CRVector3d vector where X component represents angle towards the object and y component distance
   */
  public CRVector3d getRelativeVectorTo(CRVector3d vector_, CRVector3d pivot_) {
    CRVector3d tempVector = CRVector3d.subtractVectors(pivot_, vector_);
    CRVector3d u = this.getVectorInLocalCoordinateSystem(tempVector);
    u.normalize();
   
    //distance from radial border of self to radial border of another object
    double distance = Math.hypot(position.x- vector_.x, position.y- vector_.y);
   
    //add direction:
View Full Code Here

   * @return CRVector3d vector translated to local coordinates
   */
  protected CRVector3d getVectorInLocalCoordinateSystem(CRVector3d vector_, boolean invertRotation_) {
    double rot = Math.toRadians(rotation);
    if (invertRotation_) { rot = -rot; }
    CRVector3d tempVec = new CRVector3d();
    tempVec.x = vector_.x*Math.cos(rot) + vector_.y*Math.sin(rot);
    tempVec.y = - vector_.x*Math.sin(rot) + vector_.y*Math.cos(rot);
    return tempVec;
  }
View Full Code Here

  }


  public CRVector3d getPosition() { return position; }
  public void setPosition(CRVector3d position_) {
    CRVector3d curPos = new CRVector3d(position);
    position.copyFrom(position_);
    previousPosition.copyFrom(curPos);
  }
View Full Code Here

    super(id_);
    controller = controller_;
    situatedModels = new ArrayList<CRBaseSituatedModel>();
    dynamicModels = new ArrayList<CRBaseDynamicModel>();
    scenarios = new ArrayList<String>();
    size = new CRVector3d(size_);
    isBorderless = true;
  }
View Full Code Here

 
  public ArrayList<CRBaseDynamicModel> getDynamicModels() { return dynamicModels; }
  public void setDynamicModels(ArrayList<CRBaseDynamicModel> situatedModels) { this.dynamicModels = situatedModels; }

  public CRVector3d getSize() { return size; }
  public void setSize(CRVector3d size_) { size = new CRVector3d(size_); }
View Full Code Here

  /**
   * Get current velocity based on rotation and thrustforce.
   * @return CRVector3d velocity that is always between <0;1>, i.e. does not take maxSpeed into account
   */
  public CRVector3d getVelocity() {
    CRVector3d v = new CRVector3d(getRotationAsVectorComponent(), thrustForce, 0);
    return v;
  }
View Full Code Here

TOP

Related Classes of net.lenkaspace.creeper.vo.CRVector3d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.