I brought some pictures, to make easy to understand
As you see above picture, I was on the
x tile - 3 / y tile - 2
and the destination of the portal was
x tile -3 / y tile - 7
I was able to build, even blocking entity was at the direction of destination. - So I checked in console
Console output [16:12:53] Distance: 442
[16:12:53] Angle : 0.77183651976355 | DeltaX 0.71663099351982 | DeltaY 0.69745252105559
[16:12:53] Evaluation: 3|2
[16:12:53] " (12x)
[16:12:53] Evaluation: 3|3
[16:12:53] " (9x)
[16:12:53] Evaluation: 4|3
[16:12:53] " (35x)
[16:12:53] Evaluation: 4|4
[16:12:53] " (8x)
[16:12:53] Evaluation: 5|4
[16:12:53] " (36x)
[16:12:53] Evaluation: 5|5
[16:12:53] " (7x)
[16:12:53] Evaluation: 6|5
[16:12:53] " (37x)
[16:12:53] Evaluation: 6|6
[16:12:53] " (5x)
[16:12:53] Evaluation: 7|6
[16:12:53] " (39x)
[16:12:53] Evaluation: 7|7
[16:12:53] " (4x)
[16:12:53] Evaluation: 8|7
[16:12:53] " (40x)
[16:12:53] Evaluation: 8|8
[16:12:53] " (3x)
[16:12:53] Evaluation: 9|8
[16:12:53] " (41x)
[16:12:53] Evaluation: 9|9
[16:12:53] " (1x)
[16:12:53] Evaluation: 10|9
[16:12:53] " (43x)
[16:12:53] Evaluation: 10|10
[16:12:53] Evaluation: 11|10
[16:12:53] " (43x)
[16:12:53] Evaluation: 11|11
[16:12:53] Evaluation: 12|11
[16:12:53] " (43x)
[16:12:53] Evaluation: 13|11
[16:12:53] Evaluation: 13|12
[16:12:53] " (15x)
Yes, the coordinate X shouldn't be changed but it had.
Now look at this function that DC gave me,
freeline function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function distance(x1, y1, x2, y2)
print("\169125255125Distance: "..math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))))
return math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2)))
end
function freeline(x1, y1, x2, y2)
local angle = math.atan2(y2 - y1, x2 - x1)
local deltaX = math.cos(angle)
local deltaY = math.sin(angle)
local dist = distance(x1, y1, x2, y2)
	print("\169230230230Angle : ".. math.atan2(y2 - y1, x2 - x1).." | DeltaX "..math.cos(angle).." | DeltaY "..math.sin(angle))
for i=1, dist do
	msg("Evaluation: "..math.floor((x1 + i * deltaX) / 32).."|"..math.floor((y1 + i * deltaY) / 32))
if entity(math.floor((x1 + i * deltaX) / 32),math.floor((y1 + i * deltaY) / 32), "name") == "portalkill" then
msg("\169255255255entity("..math.floor((x1 + i * deltaX) / 32)..","..math.floor((y1 + i * deltaY) / 32)..", \"name\") == \"killportal\"")
		print("loop value: "..i)
return true
end
end
	print("\169230200200--------------------------------")
return false
end
so whenever you tried to shoot the portal, it will evaluate and output dirty debugs in a console like below picture
and I calculated from given formula
1
2
--part of evaluation in freeline function.
if entity(math.floor((x1 + i * deltaX) / 32),math.floor((y1 + i * deltaY) / 32), "name") == "portalkill" then
So, ya actually I don't need to calculate it since debug told me everything. the path of freeline was like below picture
After notice of path, tested in many directions.
at this time, I was not able to build a portal reason for such path.
Tried on a slanted directon
Again, worked as planned! can't build the portal but kindly strange happens, the evaluation coordinates went broken-like, sometimes one to four in x coordinates, sometimes twelve to fifteen in x coordinates, I dunno.
Log [16:53:14] Distance: 480
[16:53:14] Angle : 0.40401062843272 | DeltaX 0.9194917782262 | DeltaY 0.39310923389614
[16:53:14] Evaluation: 1|4
[16:53:14] " (16x)
[16:53:14] Evaluation: 2|4
[16:53:14] " (14x)
[16:53:14] Evaluation: 2|5
[16:53:14] " (18x)
[16:53:14] Evaluation: 3|5
[16:53:14] " (34x)
[16:53:14] Evaluation: 4|5
[16:53:14] " (27x)
[16:53:14] Evaluation: 4|6
[16:53:14] entity(4,6, "name") == "killportal"
[16:53:14] loop value: 115
Erm, yes unexpected path. I have no idea now.