1
# tools used to animate objects in the visualized scene
2

3

4

5
function (as::ArcPointsRangeSolve)(res::Vector{Float64}, x::Vector{Float64})
6 15
  res[1] = norm(x-as.x1)^2 - as.r^2
7 15
  res[2] = norm(x-as.x2)^2 - as.r^2
8 15
  if length(res) == 3
9 15
    res[3] = norm(x-as.x3)^2 - as.r^2
10
  end
11 15
  nothing
12
end
13

14
function animatearc(vc,
15
                    drmodel::DrawObject,
16
                    as::ArcPointsRangeSolve;
17
                    N::Int=100,
18
                    delaytime::Float64=0.05,
19
                    initrot::Rotation=Rotations.Quat(1.0,0,0,0),
20
                    from::Number=0,
21
                    to::Number=1  )
22
  #
23 0
  for t in linspace(from,to,N)
24 0
    am = parameterizeArcAffineMap(t, as, initrot=initrot )
25 0
    drmodel(vc, am )
26 0
    sleep(delaytime)
27
  end
28 0
  nothing
29
end
30

31

32
function findaxiscenter!(as::ArcPointsRangeSolve)
33 15
  d = length(as.center)
34 15
  x0 = 0.5*(as.x1+as.x2)
35 15
  r = nlsolve(as, x0)
36 2
  as.center = r.zero
37 2
  vA, vB, vC = as.x1-as.center, as.x2-as.center, as.x3-as.center
38 15
  l1, l2 = norm(as.x1-as.x2), norm(as.x2-as.x3)
39 15
  halfl0 = 0.5*norm(as.x1-as.x3)
40 15
  axt = l1 < l2 ? LinearAlgebra.cross(vA,vB) : LinearAlgebra.cross(vB,vC)
41 15
  as.axis[1:3] = axt / norm(axt)
42 2
  ta = LinearAlgebra.cross(vA,vC)
43 15
  ta ./= norm(ta)
44 15
  alph = acos(halfl0/as.r)
45 15
  if norm(ta-as.axis) < 1e-4
46
    #accute
47 15
    as.angle = pi - 2*alph
48
  else
49
    # oblique
50 2
    as.angle = pi + 2*alph
51
  end
52 15
  r.f_converged
53
end

Read our documentation on viewing source code .

Loading