Skip to content

Commit

Permalink
Using more refined randomization to avoid periodicity. Added fix to t…
Browse files Browse the repository at this point in the history
…he Julia bug JuliaLang/julia#31949. Added operations to retrieve spline control points.
  • Loading branch information
apt committed Jan 9, 2021
1 parent 75fadef commit ec67705
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Paths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ path_interpolated_frames(path::Path, (t0, t1)=path_domain(path), epsilon=colline
pm = location_at(path, tm)
min_recursion < 0 &&
collinear_points(p0, pm, p1, epsilon) &&
let tr = (t0 + t1)/(1.9+rand()*0.2),
let tr = (t0 + t1)/(1.99+rand()*0.02),
pr = location_at(path, tr) # To avoid coincidences
collinear_points(p0, pr, p1, epsilon)
end ?
Expand All @@ -134,7 +134,7 @@ arc_path(center::Loc=u0(), radius::Real=1, start_angle::Real=0, amplitude::Real=
ArcPath(center, radius, start_angle, amplitude)
path_domain(path::ArcPath) = (0, path.amplitude)
location_at(path::ArcPath, ϕ::Real) =
let s = sign(path.amplitude),
let s = sign(path.amplitude*1.0), # just to circunvent a Julia bug https://github.com/JuliaLang/julia/issues/31949.
ϕ = ϕ*s
loc_from_o_vx_vy(add_pol(path.center, path.radius, path.start_angle + ϕ),
vpol(1, path.start_angle + ϕ + π, path.center.cs),
Expand Down Expand Up @@ -820,6 +820,13 @@ curve_interpolator(pts::Locs, isperiodic::Bool) =
[pt.raw[i] for i in 1:3, pt in in_world.(isperiodic ? [pts..., pts[1]] : pts)],
k=length(pts)<=3 ? 2 : 3,
periodic=isperiodic)
curve_control_points(interpolator) =
let cps = get_coeffs(interpolator)
[xyz(cps[1,j], cps[2,j], cps[3,j], world_cs)
for j in 1:size(cps, 2)]
end
curve_knots(interpolator) =
get_knots(interpolator)

convert(::Type{ClosedPolygonalPath}, path::ClosedPathSequence) =
let paths = path.paths,
Expand Down

0 comments on commit ec67705

Please sign in to comment.