math - 计算圆上最近的点
问题描述
我正在尝试计算用红色标记的点(在圆和框的角之间创建一条线)
这与返回两个圆之间的 x,y 交点的 JavaScript 函数有类似的问题?
但是,这是针对 2 个圆圈的。
我知道两者的位置,圆半径等,我如何计算到圆上那个角的最近点?
const shapeTop = this.shape.getAttribute('position').clone()
//I want to apply the position here
const geo = this.button.children[0].getAttribute('geometry')
if(!geo)
return
const halfWidth = geo.width * 0.5
const halfHeight = geo.height * 0.5
const buttonEdge = {
x: buttonPos.x + (buttonPos.x > 0 ? - halfWidth : halfWidth),
y: buttonPos.y + (buttonPos.y > 0 ? - halfHeight : halfHeight),
z: buttonPos.z,
}
解决方案
在 three.js 中,您可以像这样计算所需的点:
var vector = new THREE.Vector3(); // or Vector2
vector.copy( corner ).sub( center ).setLength( radius ).add( center );
三.js r.93
推荐阅读
- amazon-web-services - Amazon EC2 服务器偶尔冻结
- firebase - 无法使用 cli 命令登录 Firebase
- php - 使用 htaccess 在 Wordpress 中重写 URL
- python - 重写列表列表中的值
- haskell - 类型正确的功能可以不适用吗?(哈斯克尔)
- excel - Excel VBA 为特定行项应用过滤器
- hadoop - 如何一次删除 hive 中外部表的所有空/无效分区
- reactjs - 如何从 Webpack 4 React 项目编码拆分包(fontawesome)
- docker - 在容器中运行的应用程序无法连接到 VM localhost 上的 couchbase
- asp.net-mvc - DropDownListFor 未在修改的 Scaffold Razor 页面中返回选定值