Skip to content

Is raycasting possible? #1352

Answered by rcoreilly
Stingaaa asked this question in Q&A
Dec 1, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Here's an example for a plane, which I use for my neural network visualization, here: https://github.com/emer/emergent/blob/main/netview/events.go -- see LayerUnitAtPoint, which takes an image point and returns the x,y coordinates in the plane. The core code is here:

ray := lo.RayPick(pos)
// layer is in XZ plane with norm pointing up in Y axis
// offset is 0 in local coordinates
plane := math32.Plane{Norm: math32.Vec3(0, 1, 0), Off: 0}
pt, ok := ray.IntersectPlane(plane)

lo is an xyz.Solid

Basically, the math32.Ray object has all the methods you might need to find more specific intersections.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Stingaaa
Comment options

Answer selected by Stingaaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants