射线 注意:构造之后只读,对于实例中的 origin/Direction/Unit 进行修改是无意义的
| | | |
---|
射线某个方向投影的 point = origin + cos(theta) *(unit) (也表示点到射线的最先距离) | | | |
参数名称 | 类别 | 默认 | 描述 |
ray | Ray | | |
point | Vector3 | | |
返回类型 | | | 概要 |
Vector3 | | | |
local origin = Vector3.New(0,0,0)
local direct = Vector3.New(0,1,0)
local ray = Ray.New(origin, direct)
local unitRay = ray.Unit
local pos = Vector3.New(50,10,10)
local d = ray:Distance(pos)
local v3 = ray:ClosestPoint(pos)
print("Unit Ray:"..tostring(unitRay))
print("Ray Origin x:"..tostring(ray.Origin.x).." y:"..tostring(ray.Origin.y).." z:"..tostring(ray.Origin.z))
print("Ray Direction x:"..tostring(ray.Direction.x).." y:"..tostring(ray.Direction.y).." z:"..tostring(ray.Direction.z))
print("d:"..tostring(d))
print("v3:x:"..tostring(v3.x).." y:"..tostring(v3.y).." z:"..tostring(v3.z))