So if I change the lattice (see dir2d), and i.e. y is 0.5 or -0.5 instead of 1 and -1, ray will jump previous point B and new point A will not coincide, and I have tried but I cannot figure out how to change point A values (I guess there is the problem) to solve this stuff that is causing me headaches
If I change the random coordinates dir2d to 1 unit interval everything works, if one of the 4 position in dir2d is i.e 0.5 when the spline is traced a gap is shown.
I was told that multiplying dir for a constant i.e. v=0.5 I could change pos in the ray, I have tried in different vays but it did not work and is crucial that dir2d can have not just 1 unit jump.
Please help me I have to solve this for my uni project!
Thanks a lot Tim.
fn drawLineBetweenTwoPoints pointA pointB col=
ss = SplineShape pos:pointA renderable:true thickness:0.05 wirecolor:col
addKnot ss 1 #corner #line PointA
addKnot ss 1 #corner #line PointB
return dirArr[random 1 dirArr.count]
--return dirArr[random 1 dirArr.count]
--) THIS IS THE ONE THAT EVENTUALLY WORKS
function plot steps trace:false drawMode:1=
if trace then clearlistener()
r=ray [0,0,0] [1,0,0]
for i = 1 to steps do
local pc=((i as float/steps)*100) as integer
displaytempprompt ("Processing: " + pc as string +"% done") 1
local c=(i as float/steps)*255
col=color c c c 255
-- new ray
--v= ( if abs dir.x == 0.5 then 0.5 else 1) -- I mean IT SHOULD BE SOMETHING LIKE THAT!
pointA= rayArr[rayArr.count].pos + (rayArr[rayArr.count].dir)--*v)
r= ray pointA dir
-- test that this ray / dir hasn't been used yet
-- one of two modes:
-- 1: don't use same space and direction
-- 2: don't use same space
if drawMode==1 then
for test in rayArr do if (r.pos==test.pos AND r.dir==test.dir) then (draw=false;continue)
for test in rayArr do if (r.pos+r.dir==test.pos) then (draw=false;continue)
-- draw the line
if draw then
drawLineBetweenTwoPoints pointA pointB col
append rayArr r
-- trace result
if trace then format "% %\n" pointA pointB
max zoomext sel all
messagebox("Number of splines" + rayArr.count as String) beep:false
plot 200 drawMode:0