You need a minimum of 3 points to calculate a normal, along with knowing which side of the triangle made from those points is the front - usually this is determined by the winding of the points (DBPro uses counter-clockwise, or CCW).
Example code (using CCW):
p1 = new vector3(1, 0, 0)
p2 = new vector3(0, 0, 1)
p3 = new vector3(1, 0, 1)
N = CalculateNormal(p1, p2, p3)
print x vector3(N)
print y vector3(N)
print z vector3(N)
wait key
function CalculateNormal(p1, p2, p3)
U = new vector3()
subtract vector3 U, p1, p2
V = new vector3()
subtract vector3 V, p1, p3
nx = (y vector3(U) * z vector3(V)) - (z vector3(U) * y vector3(V))
ny = (z vector3(U) * x vector3(V)) - (x vector3(U) * z vector3(V))
nz = (x vector3(U) * y vector3(V)) - (y vector3(U) * x vector3(V))
N = new vector3( nx, ny, nz )
delete vector3 U
delete vector3 V
endfunction N
If you want clockwise winding instead, either negate the result, or swap the U/V vectors so that U=p1-p3 and V=p1-p2
[edit]Doh, I just realised you want 2D reflection, so you need to calculate the normal for that line.
I've never needed this myself - as long as the lines the object is bouncing on are either horizontal or vertical, what I do is determine how far the object has moved past the wall and adjust by that distance to the other side of the wall.
sync on
sync rate 0
x as float
y as float
xspeed as float
yspeed as float
x = 105
y = 105
xspeed = rnd(100) / 100.0
yspeed = rnd(100) / 100.0
do
` cls
line 100, 0, 100, screen height()
line 400, 0, 400, screen height()
line 0, 100, screen width(), 100
line 0, 307, screen width(), 307
x = x + xspeed
if x < 100.0
x = 100.0 + (100.0 - x)
xspeed = xspeed * -1.0
endif
if x > 400.0
x = 400.0 - (x - 400.0)
xspeed = xspeed * -1.0
endif
y = y + yspeed
if y < 100.0
y = 100.0 + (100.0 - y)
yspeed = yspeed * -1.0
endif
if y > 307.0
y = 307.0 - (y - 307.0)
yspeed = yspeed * -1.0
endif
dot x, y
sync
loop