Skip to content

KeitaNakamura/PointToTriangle.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PointToTriangle.jl

Fast point-to-triangle distance computation in 3D

This program is mostly based on the study by Jones (1995).

CI codecov

Installation

pkg> add https://github.com/KeitaNakamura/PointToTriangle.jl.git

Usage

Using the isbitstype type of AbstractVector, such as SVector in StaticArrays.jl, is recommended for sake of performance.

julia> using PointToTriangle, StaticArrays

julia> a, b, c = rand(SVector{3}), rand(SVector{3}), rand(SVector{3});

julia> tri = PointToTriangle.Triangle(a, b, c);

julia> p = rand(SVector{3});

julia> d = PointToTriangle.vector(p, tri) # compute point-to-triangle distance vector
3-element SVector{3, Float64} with indices SOneTo(3):
  0.21019419472595702
 -0.2926549510617162
 -0.1669372773882311

Visualizing results

Plots.jl

 julia> using Plots

 julia> plotlyjs()

 julia> plot(map(Tuple, [a,b,c,a]))

 julia> plot!(map(Tuple, [p,p+d]))

Makie.jl

 julia> using GLMakie

 julia> lines([a b c a])

 julia> lines!([p p+d])