Use qsort method for sorts array
Good day.
In scene present $Camera01 and points helper array.[Point01,Point02,....]
I want construct spline from points array, and use next script
------------------------------------------------------------
points = $Point* as array
fer=#()
for r=1 to points.count do
(
in coordsys $Camera01 ff = points[r].pos
append fer ff
)
fn compareFN v1 v2 =
(
local d = v1[2]- v2[2]
case of
(
(d < 0.): -1
(d > 0.): 1
default: 0
)
)
qsort fer compareFN
ss = SplineShape pos:fer[1]
addNewSpline ss
addKnot ss 1 #corner #line fer[1]
for r=2 to (fer.count) do
(
addKnot ss 1 #corner #line fer[r]
updateShape ss
ss
)
-------------------------------------------------
Use function compareFN, I try sort points array, for next construct spline,in order enlarge "in coordsys $Camera01 Point.y" value
fn compareFN v1 v2 =
(
local d = v1[2]- v2[2]
case of
(
(d < 0.): -1
(d > 0.): 1
default: 0
)
)
But after script end, resalt spline locate in unexpected place.
-------------------------------------------------------------------
.... qsort fer compareFN - use "in coordsys $Camera01 Point.y" value as
"in coordsys world" value
How can I avoid this situation?
Attachment | Size |
---|---|
serching.max | 236 KB |