Find the intersection of a line with a plane: Difference between revisions

m
→‎{{header|Wren}}: Added libheader.
(Added Easylang)
m (→‎{{header|Wren}}: Added libheader.)
 
(One intermediate revision by the same user not shown)
Line 2,088:
=={{header|Wren}}==
{{trans|Kotlin}}
{{libheader|Wren-vector}}
<syntaxhighlight lang="ecmascriptwren">classimport Vector3D"./vector" for {Vector3
construct new(x, y, z) {
_x = x
_y = y
_z = z
}
 
x { _x }
y { _y }
z { _z }
 
+(v) { Vector3D.new(_x + v.x, _y + v.y, _z + v.z) }
 
-(v) { Vector3D.new(_x - v.x, _y - v.y, _z - v.z) }
 
*(s) { Vector3D.new(s * _x, s * _y, s * _z) }
 
dot(v) { _x * v.x + _y * v.y + _z * v.z }
 
toString { "(%(_x), %(_y), %(_z))" }
}
 
var intersectPoint = Fn.new { |rayVector, rayPoint, planeNormal, planePoint|
Line 2,118 ⟶ 2,099:
}
 
var rv = Vector3DVector3.new(0, -1, -1)
var rp = Vector3DVector3.new(0, 0, 10)
var pn = Vector3DVector3.new(0, 0, 1)
var pp = Vector3DVector3.new(0, 0, 5)
var ip = intersectPoint.call(rv, rp, pn, pp)
System.print("The ray intersects the plane at %(ip).")</syntaxhighlight>
9,482

edits