formZ SDK | 5.0 API Reference | System | Math

# fz_math_3d_dist_2_lines

Description

Calculates the shortest distance between two 3d lines in 3d space.
The two 3d points, where the shortest distance occurs are also returned (pt1 on line 1 and pt2 on line 2). If the two lines lie in the same plane pt1 and pt2 are the same. If the two lines are parallel, pt1 is line1_start and pt2 is the perpendicular projection of pt1 on line 2.
How the two lines relate in 3d is returned in the kase parameter.
0 : lines don't intersect in one point and are not parallel
1 : lines intersect in one point and are not parallel (i.e. dist = 0.0 and pt1 == pt2)
2 : lines are parallel (dist is constant between the lines, pt1 and pt2 chosen arbitrarily)

Plugin Prototype

fzrt_error_td fz_math_3d_dist_2_lines(

fz_xyz_td * | line1_start,
fz_xyz_td * | line1_end,
fz_xyz_td * | line2_start,
fz_xyz_td * | line2_end,
double * | dist,
fz_xyz_td * | pt1,
fz_xyz_td * | pt2,
fzrt_int * | kase )

Parameters

line1_start [Input]

start point of 3d line segment 1

line1_end [Input]

end point of 3d line segment 1

line2_start [Input]

start point of 3d line segment 2

line2_end [Input]

end point of 3d line segment 2

dist [Result, Optional]

shortest distance between the lines

pt1 [Result, Optional]

3d point on line segment 1 where the shortest distance occurs

pt2 [Result, Optional]

3d point on line segment 2 where the shortest distance occurs

kase [Result, Optional]

how the line segments relate

Returns

Error codes

Availability

5.0.0.0

Example Files

util_math_3d.fsl

Function Set

fz_math_fset

Defined in

fz_math_api.h