two points of first line, two points of second line
a number -> parallelism -> distance line line a vertex -> intersection -> point of intersection
| |
|
|
| |
Implementation
01 function intersect_lineline( ua, ub, va, vb )
02 dim u: u = vector_create( ua, ub )
03 dim v: v = vector_create( va, vb )
04 dim w: w = vector_create( ua, va )
05 dim n: n = vector_cross( u, v )
06 dim p: p = vector_length( n )
07 dim q: q = vector_dot( vector_cross( w, v ), n )
08 dim d: d = vector_dot( w, n )
09 if( abs( d ) <= NUMBER_ZERO ) then
10 if( abs( p ) <= NUMBER_ZERO ) then
11 intersect_lineline = vertex_length( ua, vertex_project( va, vb, ua ) )
12 else
13 intersect_lineline = vertex_translate( ua, vector_scale( u, q / ( p * p ) ) )
14 end if
15 else
16 intersect_lineline = abs( d / p )
17 end if
18 end function
|
|
| |
|
|
|