Cylindrical.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @author moraxy / https://github.com/moraxy
  3. */
  4. QUnit.module( "Cylindrical" );
  5. QUnit.test( "constructor", function ( assert ) {
  6. var a = new THREE.Cylindrical();
  7. var radius = 10.0;
  8. var theta = Math.PI;
  9. var y = 5;
  10. assert.strictEqual( a.radius, 1.0, "Default values: check radius" );
  11. assert.strictEqual( a.theta, 0, "Default values: check theta" );
  12. assert.strictEqual( a.y, 0, "Default values: check y" );
  13. a = new THREE.Cylindrical( radius, theta, y );
  14. assert.strictEqual( a.radius, radius, "Custom values: check radius" );
  15. assert.strictEqual( a.theta, theta, "Custom values: check theta" );
  16. assert.strictEqual( a.y, y, "Custom values: check y" );
  17. } );
  18. QUnit.test( "set", function ( assert ) {
  19. var a = new THREE.Cylindrical();
  20. var radius = 10.0;
  21. var theta = Math.PI;
  22. var y = 5;
  23. a.set( radius, theta, y );
  24. assert.strictEqual( a.radius, radius, "Check radius" );
  25. assert.strictEqual( a.theta, theta, "Check theta" );
  26. assert.strictEqual( a.y, y, "Check y" );
  27. } );
  28. QUnit.test( "clone", function ( assert ) {
  29. var radius = 10.0;
  30. var theta = Math.PI;
  31. var y = 5;
  32. var a = new THREE.Cylindrical( radius, theta, y );
  33. var b = a.clone();
  34. assert.propEqual( a, b, "Check a and b are equal after clone()" );
  35. a.radius = 1;
  36. assert.notPropEqual( a, b, "Check a and b are not equal after modification" );
  37. } );
  38. QUnit.test( "copy", function ( assert ) {
  39. var radius = 10.0;
  40. var theta = Math.PI;
  41. var y = 5;
  42. var a = new THREE.Cylindrical( radius, theta, y );
  43. var b = new THREE.Cylindrical().copy( a );
  44. assert.propEqual( a, b, "Check a and b are equal after copy()" );
  45. a.radius = 1;
  46. assert.notPropEqual( a, b, "Check a and b are not equal after modification" );
  47. } );
  48. QUnit.test( "setFromVector3", function ( assert ) {
  49. var a = new THREE.Cylindrical( 1, 1, 1 );
  50. var b = new THREE.Vector3( 0, 0, 0 );
  51. var c = new THREE.Vector3( 3, - 1, - 3 );
  52. var expected = new THREE.Cylindrical( Math.sqrt( 9 + 9 ), Math.atan2( 3, - 3 ), - 1 );
  53. a.setFromVector3( b );
  54. assert.strictEqual( a.radius, 0, "Zero-length vector: check radius" );
  55. assert.strictEqual( a.theta, 0, "Zero-length vector: check theta" );
  56. assert.strictEqual( a.y, 0, "Zero-length vector: check y" );
  57. a.setFromVector3( c );
  58. assert.ok( Math.abs( a.radius - expected.radius ) <= eps, "Normal vector: check radius" );
  59. assert.ok( Math.abs( a.theta - expected.theta ) <= eps, "Normal vector: check theta" );
  60. assert.ok( Math.abs( a.y - expected.y ) <= eps, "Normal vector: check y" );
  61. } );
粤ICP备19079148号