TrigonometryTest.java 755 B

12345678910111213141516171819202122232425262728
  1. package com.jme3.math;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import static org.junit.Assert.fail;
  5. import com.jme3.math.FastMath;
  6. import com.jme3.math.Vector2f;
  7. import org.junit.Test;
  8. public class TrigonometryTest {
  9. @Test
  10. public void testVector2(){
  11. Vector2f original = new Vector2f(1, 2);
  12. Vector2f recreated = new Vector2f();
  13. float angle = original.getAngle();
  14. float length = original.length();
  15. recreated.set( FastMath.cos(angle), FastMath.sin(angle) );
  16. recreated.multLocal(length);
  17. assertEquals( original.getX(), recreated.getX(), 0.000001 );
  18. assertEquals( original.getY(), recreated.getY(), 0.000001 );
  19. }
  20. }