HetaoZ / TriangleIntersect.jl

Fast ray-triangle intersections for raytracing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status

TriangleIntersect

Find if and where a light ray intersects a triangle (in 3D of course). This is optimized for speed. See nice general explanation here

Installation

Pkg.clone("git://github.com/JuliaGeometry/TriangleIntersect.jl.git")

#Usage Import and create some points:

using TriangleIntersect
a = Point(0,0,0)
b = Point(1,0,0)
c = Point(0,1,0)

Create a triangle

t = Triangle(b,a,c)

Cast a ray:

r = Ray(Point(0.1,0.1,1), Point(0.1,0.1,-1))

Check the intersection:

intersect(r, t) # -> Intersection(Point(0.2,0.2,0.0),1.02,true)

The Intersection type is simply defined as:

immutable Intersection
    ip::Point # intersecting point
    id::Float64 # intersecting distance
    is_intersection::Bool
end

About

Fast ray-triangle intersections for raytracing

License:Other


Languages

Language:Julia 100.0%