提交 e713a499 编写于 作者: M Mugen87

Cylindrical: Support for Cylindrical Coordinates

上级 4984e793
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">A point's cylindrical coordinates.</div>
<h2>Constructor</h2>
<h3>[name]( [page:Float radius], [page:Float theta], [page:Float y] )</h3>
<div>
radius -- [page:Float] distance from the origin to a point in the x-z plane<br />
theta -- [page:Float] counterclockwise angle in the x-z plane measured in radians from the positive z-axis<br />
y -- [page:Float] height above the x-z plane
</div>
<h2>Properties</h2>
<h3>[property:Float radius]</h3>
<h3>[property:Float theta]</h3>
<h3>[property:Float y]</h3>
<h2>Methods</h2>
<h3>[method:Cylindrical set]( [page:Float radius], [page:Float theta], [page:Float y] ) [page:Cylindrical this]</h3>
<div>
Sets values of this cylindrical's component coordinates.
</div>
<h3>[method:Cylindrical copy]( [page:Cylindrical c] ) [page:Cylindrical this]</h3>
<div>
Copies value of *c* to this cylindrical.
</div>
<h3>[method:Cylindrical clone]() [page:Cylindrical this]</h3>
<div>
Clones this cylindrical.
</div>
<h3>[method:Cylindrical setFromVector3]( [page:Vector3 v] ) [page:Cylindrical this]</h3>
<div>
Sets this object from the vector *v*.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -238,6 +238,7 @@ var list = {
[ "Box2", "api/math/Box2" ],
[ "Box3", "api/math/Box3" ],
[ "Color", "api/math/Color" ],
[ "Cylindrical", "api/math/Cylindrical" ],
[ "Euler", "api/math/Euler" ],
[ "Frustum", "api/math/Frustum" ],
[ "Interpolant", "api/math/Interpolant" ],
......
......@@ -102,6 +102,7 @@ export { Triangle } from './math/Triangle.js';
export { Spline } from './math/Spline.js';
export { _Math as Math } from './math/Math.js';
export { Spherical } from './math/Spherical.js';
export { Cylindrical } from './math/Cylindrical.js';
export { Plane } from './math/Plane.js';
export { Frustum } from './math/Frustum.js';
export { Sphere } from './math/Sphere.js';
......
/**
* @author Mugen87 / https://github.com/Mugen87
*
* 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;
}
Cylindrical.prototype = {
constructor: Cylindrical,
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( vec3 ) {
this.radius = Math.sqrt( vec3.x * vec3.x + vec3.z * vec3.z );
this.theta = Math.atan2( vec3.x, vec3.z );
this.y = vec3.y;
return this;
}
};
export { Cylindrical };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册