Examples of MathVector


Examples of logisticspipes.utils.MathVector

 
  private int[] getCursor(IHeadUpDisplayRendererProvider renderer) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.thePlayer;
   
    MathVector playerView = MathVector.getFromAngles((270 - player.rotationYaw) / 360 * -2 * Math.PI, (player.rotationPitch) / 360 * -2 * Math.PI);
    MathVector playerPos = new MathVector();
    playerPos.X = player.posX;
    playerPos.Y = player.posY;
    playerPos.Z = player.posZ;

    MathVector panelPos = new MathVector();
    panelPos.X = renderer.getX() + 0.5;
    panelPos.Y = renderer.getY() + 0.5;
    panelPos.Z = renderer.getZ() + 0.5;
   
    MathVector panelView = new MathVector();
    panelView.X = playerPos.X - panelPos.X;
    panelView.Y = playerPos.Y - panelPos.Y;
    panelView.Z = playerPos.Z - panelPos.Z;

    panelPos.add(panelView, 0.44D);

    double d = panelPos.X * panelView.X + panelPos.Y * panelView.Y + panelPos.Z * panelView.Z;
    double c = panelView.X * playerPos.X + panelView.Y * playerPos.Y + panelView.Z * playerPos.Z;
    double b = panelView.X * playerView.X + panelView.Y * playerView.Y + panelView.Z * playerView.Z;
    double a = (d - c) / b;
   
    MathVector viewPos = new MathVector();
    viewPos.X = playerPos.X + a * playerView.X - panelPos.X;
    viewPos.Y = playerPos.Y + a * playerView.Y - panelPos.Y;
    viewPos.Z = playerPos.Z + a * playerView.Z - panelPos.Z;
   
    MathVector panelScalVector1 = new MathVector();
   
    if(panelView.Y == 0) {
      panelScalVector1.X = 0;
      panelScalVector1.Y = 1;
      panelScalVector1.Z = 0;
    } else {
      panelScalVector1 = panelView.getOrtogonal(-panelView.X, null, -panelView.Z).makeVectorLength(1.0D);
    }
   
    MathVector panelScalVector2 = new MathVector();
   
    if(panelView.Z == 0) {
      panelScalVector2.X = 0;
      panelScalVector2.Y = 0;
      panelScalVector2.Z = 1;
    } else {
      panelScalVector2 = panelView.getOrtogonal(1.0D, 0.0D, null).makeVectorLength(1.0D);
    }
   
    if(panelScalVector1.Y == 0) {
      return new int[]{};
    }
   
    double cursorY = -viewPos.Y / panelScalVector1.Y;
   
    MathVector restViewPos = viewPos.clone();
    restViewPos.X += cursorY*panelScalVector1.X;
    restViewPos.Y = 0;
    restViewPos.Z += cursorY*panelScalVector1.Z;
   
    double cursorX;
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test constructor.
   */
  public void testConstructor() {
    MathVector v = new MathVector(0);
    assertEquals(0, v.getColumns());
    assertEquals(0, v.size());
    assertEquals(1, v.getRows());
    v = new MathVector(1);
    assertEquals(1, v.getColumns());
    assertEquals(1, v.size());
    assertEquals(1, v.getRows());
    assertEquals(0.0, v.getElement(0));
    v = new MathVector(2);
    assertEquals(2, v.getColumns());
    assertEquals(2, v.size());
    assertEquals(1, v.getRows());
    assertEquals(0.0, v.getElement(0));
    assertEquals(0.0, v.getElement(1));
    v = new MathVector(3);
    assertEquals(3, v.getColumns());
    assertEquals(3, v.size());
    assertEquals(1, v.getRows());
    assertEquals(0.0, v.getElement(0));
    assertEquals(0.0, v.getElement(1));
    assertEquals(0.0, v.getElement(2));
  }
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test constructor exceptions.
   */
  public void testConstructorExceptions() {
    try {
      new MathVector(-1);
      fail();
    } catch (NegativeArraySizeException e) {
      assertTrue(true);
    } catch (Exception e) {
      fail();
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test set element.
   */
  public void testSetElement() {
    MathVector v = new MathVector(2);

    v.setElement(0, 42.42);
    assertEquals(42.42, v.getElement(0));
    assertEquals(0.0, v.getElement(1));
    v.setElement(1, 23.23);
    assertEquals(42.42, v.getElement(0));
    assertEquals(23.23, v.getElement(1));
  }
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test set element exceptions.
   */
  public void testSetElementExceptions() {
    MathVector v = new MathVector(2);

    try {
      v.setElement(3, 1.2);
      fail();
    } catch (ArrayIndexOutOfBoundsException e) {
      assertTrue(true);
    } catch (Exception e) {
      fail();
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test copy.
   */
  public void testCopy() {
    MathVector v1 = new MathVector(3);

    v1.setElement(0, 1.2);
    v1.setElement(1, 3.4);
    v1.setElement(1, 6.7);

    MathVector v2 = v1.copy();

    assertNotNull(v1);
    assertNotNull(v2);
    // copy() should return a copy, not the same object
    assertFalse(v1 == v2);

    assertEquals(v1.getElement(0), v2.getElement(0));
    assertEquals(v1.getElement(1), v2.getElement(1));
    assertEquals(v1.getElement(2), v2.getElement(2));
  }
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test mult with scalar.
   */
  public void testMultWithScalar() {
    MathVector v = new MathVector(2);

    v.setElement(0, 1.2);
    v.setElement(1, 3.4);

    assertEquals(1.2, v.getElement(0));
    assertEquals(3.4, v.getElement(1));

    v.multWithScalar(5);

    assertEquals(6.0, v.getElement(0));
    assertEquals(17.0, v.getElement(1));
  }
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test scalar product.
   */
  public void testScalarProduct() {
    MathVector v1 = new MathVector(2), v2 = new MathVector(2);
    v1.setElement(0, 1.25);
    v1.setElement(1, 3.75);
    v2.setElement(0, 8.25);
    v2.setElement(1, -4.5);
    assertEquals(-105d / 16, v1.scalarProduct(v2));
  }
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test scalar product exceptions.
   */
  public void testScalarProductExceptions() {
    try {
      new MathVector(2).scalarProduct(new MathVector(3));
      fail();
    } catch (MatrixException e) {
      assertTrue(true);
    } catch (Exception e) {
      fail();
View Full Code Here

Examples of org.jamesii.core.math.MathVector

  /**
   * Test vector product.
   */
  public void testVectorProduct() {
    MathVector v1 = new MathVector(3), v2 = new MathVector(3);
    v1.setElement(0, 1);
    v1.setElement(1, 2);
    v1.setElement(2, 4);
    v2.setElement(0, -8);
    v2.setElement(1, 5);
    v2.setElement(2, 1.5);

    MathVector v3 = v1.vectorProduct(v2);

    assertEquals(-17.0, v3.getElement(0));
    assertEquals(-33.5, v3.getElement(1));
    assertEquals(21.0, v3.getElement(2));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.