You can find the normal of the black line very easily.
If the vector of the black line is [x,y] then its normal would be [y,-x] or [-y,x], depending on which direction you want the normal to face.
In this case, based on the image given and assuming the red and green lines start at coordinate [0,0], the vector of the first green line would be [-y, x]. Find the distance from point [0,0] (beginning of red and green lines) from the black line AB and this will give you the magnitude of the vector for that first green line.
Once you know the points along the black line where the red and green hit, then you can calculate the final green line which projects along the black line. Simply subtract the two points and you're done. If you want, you can normalize the vector and keep the direction and magnitude separate.
Here's some DBP code demonstrating the problem and solution:
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, November 07, 2010
a# = 340
bx# = cos(a#)
by# = sin(a#)
bm = 400
sync on
sync rate 60
do
cls
rem control the white line's angle
if upkey() then a# = wrapvalue(a#-2)
if downkey() then a# = wrapvalue(a#+2)
bx# = cos(a#)
by# = sin(a#)
x = mousex()
y = mousey()
l# = sqrt(x^2 + y^2)
rx# = x / l#
ry# = y / l#
rem ==============================
rem show the "known" line segments
rem ==============================
ink rgb(255, 255, 255),0
line 30, 300, 30+bx#*bm, 300+by#*bm
ink rgb(255,0,0),0
gosub lineIntersection
line 0, 0, rix, riy
rem ==============================
rem calculate the "green" lines
rem ==============================
ink rgb(0,255,0),0
rem The "red" line starts at [0,0]. We need to
rem know the distance from that starting point
rem to the "white" line. Use the formula for
rem calculating the distance of a point from a line
tx = bx#*bm
ty = by#*bm
n# = ((0-30)*tx) + ((0-300)*ty)
d# = tx^2 + ty^2
u# = n# / d#
ix# = 30 + tx*u#
iy# = 300 + ty*u#
dist# = sqrt(ix#^2 + iy#^2)
gx = -by#*dist#
gy = bx#*dist#
line 0,0,gx,gy
g2x = rix - gx
g2y = riy - gy
line gx, gy, gx+g2x, gy+g2y
rem green vector which goes from [0,0] to "white" line
rem This vector is displayed as normalized with "M"
rem being the magnitude (a scaler) vector.
text 400,10, "Green Vector X: "+str$(-by#)
text 400,20, "Green Vector Y: "+str$(bx#)
text 400,30, "Green Vector M: "+str$(dist#)
rem this is the green vector which projects along the "white"
rem line. The vector components contain both direction and magnitude
rem and has not been normalized.
text 400,50, "Green Vector X: "+str$(g2x)
text 400,60, "Green Vector Y: "+str$(g2y)
sync
loop
lineIntersection:
cx = 30
cy = 300
dx = 30+bx#*bm
dy = 300+by#*bm
n# = ((dx-cx) * -cy) - ((dy-cy) * -cx)
d# = ((dy-cy) * x) - ((dx-cx) * y)
t# = n# / d#
rix = x*t#
riy = y*t#
RETURN
My example refers to the black line as "white" for obvious visual reasons and represented by the vector components BX and BY, which is normalized.
Your signature has been erased by a mod please reduce it to 600 x 120.