1 Star 0 Fork 0

超腾开源/go-three-math

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cylindrical.go 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
超腾开源 提交于 2020-08-30 19:49 . source code
// Copyright 2017-2020 The ShadowEditor Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//
// For more information, please visit: https://github.com/tengge1/ShadowEditor
// You can also visit: https://gitee.com/tengge1/ShadowEditor
//
// This package is translated from three.js, visit `https://github.com/mrdoob/three.js`
// for more information.
package three
import (
"math"
)
// NewCylindrical create a new Cylindrical
func NewCylindrical(radius, theta, y float64) *Cylindrical {
return &Cylindrical{radius, theta, y}
}
// Cylindrical :
type Cylindrical struct {
Radius float64 // distance from the origin to a point in the x-z plane
Theta float64 // counterclockwise angle in the x-z plane measured in radians from the positive z-axis
Y float64 // height above the x-z plane
}
// Set :
func (c Cylindrical) Set(radius, theta, y float64) *Cylindrical {
c.Radius = radius
c.Theta = theta
c.Y = y
return &c
}
// Clone :
func (c Cylindrical) Clone() *Cylindrical {
return &Cylindrical{c.Radius, c.Theta, c.Y}
}
// Copy :
func (c Cylindrical) Copy(other *Cylindrical) *Cylindrical {
c.Radius = other.Radius
c.Theta = other.Theta
c.Y = other.Y
return &c
}
// setFromVector3 :
func (c Cylindrical) setFromVector3(v Vector3) *Cylindrical {
return c.SetFromCartesianCoords(v.X, v.Y, v.Z)
}
// SetFromCartesianCoords :
func (c Cylindrical) SetFromCartesianCoords(x, y, z float64) *Cylindrical {
c.Radius = math.Sqrt(x*x + z*z)
c.Theta = math.Atan2(x, z)
c.Y = y
return &c
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/tengge1/go-three-math.git
[email protected]:tengge1/go-three-math.git
tengge1
go-three-math
go-three-math
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385