-
Notifications
You must be signed in to change notification settings - Fork 4
/
Cylindrical.js
executable file
·65 lines (39 loc) · 1.14 KB
/
Cylindrical.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Copyright © 2010-2021 three.js authors
*
* Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system
*
*/
function Cylindrical( radius, theta, y ) {
this.radius = ( radius !== undefined ) ? radius : 1.0; // distance from the origin to a point in the x-z plane
this.theta = ( theta !== undefined ) ? theta : 0; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis
this.y = ( y !== undefined ) ? y : 0; // height above the x-z plane
return this;
}
Object.assign( Cylindrical.prototype, {
set: function ( radius, theta, y ) {
this.radius = radius;
this.theta = theta;
this.y = y;
return this;
},
clone: function () {
return new this.constructor().copy( this );
},
copy: function ( other ) {
this.radius = other.radius;
this.theta = other.theta;
this.y = other.y;
return this;
},
setFromVector3: function ( v ) {
return this.setFromCartesianCoords( v.x, v.y, v.z );
},
setFromCartesianCoords: function ( x, y, z ) {
this.radius = Math.sqrt( x * x + z * z );
this.theta = Math.atan2( x, z );
this.y = y;
return this;
}
} );
export { Cylindrical };