Skip to content

Commit

Permalink
Added fillet curve functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Mattheus-Moerman committed Jul 3, 2024
1 parent a3fd28e commit 3710216
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 7 additions & 2 deletions examples/demo_filletcurve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using Random
# Set seed so demo performs the same each time
Random.seed!(1)

testCase = 6
testCase = 11

if testCase == 1
V = Point{3,Float64}[ [0.0,0.0,0.0], [10.0,0.0,0.0]]
Expand All @@ -33,6 +33,7 @@ elseif testCase == 6
d = 10.0
nc = 12
V = circlepoints(d,nc)
close_loop = false
elseif testCase == 7
V = Point{3,Float64}[ [-2.0,0.0,0.0], [-1.0,0.0,0.0], [0.0,0.0,0.0], [1.0,-1.0,1.0], [2.0,1.0,0.0], [3.0,2.0,8.0], [5.0,0.0,0.0], [7.0,0.0,0.0]]
close_loop = false
Expand All @@ -51,10 +52,14 @@ elseif testCase == 10
V[i] = Point{3,Float64}(v[1],v[2],v[3]+20.0)
end
close_loop = true
elseif testCase == 11
d = 10.0
V = Point{3,Float64}[ [-d,-d,0.0], [d,-d,0.0], [d,d,0.0], [-d,d,0.0]]
close_loop = true
end


rMax = nothing
rMax = [2.0,3.0,0.0,5.0] #nothing

VC = filletcurve(V; rMax=rMax, constrain_method = :max, n=25, close_loop = close_loop, eps_level = 1e-6)
# VC2,_ = evenly_sample(VC,100)
Expand Down
12 changes: 5 additions & 7 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4649,7 +4649,7 @@ function filletcurve(V::Vector{Point{NV,TV}}; rMax::Union{Vector{T},T,Nothing}=n
end

e1 = VP[2]-VP[1]
e2 = VP[3]-VP[3]
e2 = VP[3]-VP[2]
lp = 0.0
i_last = length(VP)-1
L = [norm(VP[i+1]-VP[i]) for i in 1:i_last]
Expand Down Expand Up @@ -4712,8 +4712,8 @@ function filletcurve(V::Vector{Point{NV,TV}}; rMax::Union{Vector{T},T,Nothing}=n
rFit = l/tan(β)
if !isnothing(r) && r<=rFit
rNow = r
lNow = r*tan(β) # Update as as radius used is smaller
if tan(β)*rNow == l
lNow = rNow*tan(β) # Update as as radius used is smaller
if lNow == l
fullRound = true
else
fullRound = false
Expand All @@ -4726,10 +4726,8 @@ function filletcurve(V::Vector{Point{NV,TV}}; rMax::Union{Vector{T},T,Nothing}=n

if rNow > 0
d = abs(rNow/cos(β))
S1 = mapreduce(permutedims,vcat,[-m1,normalizevector(cross(n3,-m1)),n3])
S2 = one(RotMatrix{3,Float64})
Q = RotMatrix3{Float64}(S1\S2)

Q = RotMatrix3{Float64}(reduce(hcat,[-m1,normalizevector(cross(n3,-m1)),n3]))

m1p = Q'*(-m1)
a = atan(m1p[2]/m1p[1])

Expand Down

0 comments on commit 3710216

Please sign in to comment.