sds_inters

int sds_inters (const sds_point point1, const sds_point point2, const sds_point point3, const sds_point point4, int mode, sds_point interspt);


Find where these lines intersect.


This function finds the intersection point of two lines.

The arguments point1 and point2 represent the starting and ending points for the first line segment, while point3 and point4 are the starting and ending points for the second line segment.

The mode argument controls whether the line segments must actually cross:

Mode Meaning
0 The lines do not need to cross.
1 The lines must cross.

When mode is 1 and the line segments do not intersect, sds_inters returns RTERROR.

The interspt argument is the point at which the two lines intersect.

This function returns RTERROR or RTNORM.

Example

int cross;

cross = 1;

sds_point firstpt,secondpt,thirdpt,fourthpt,interspt;

sds_getpoint(NULL,"\nFirst point for line 1: ",firstpt);

sds_getpoint(firstpt,"\nSecond point: ",secondpt);

sds_getpoint(NULL,"\nFirst point for line 2: ",thirdpt);

sds_getpoint(thirdpt,"\nSecond point: ",fourthpt);

returni=sds_inters(firstpt,secondpt,thirdpt,fourthpt,cross,intpt);

if (returni != 5100)

sds_printf("\nThese two line segments do not intersect");

if (returni == 5100)

sds_printf("\nIntersection: (%f,%f,%f)", intpt[0],intpt[1],intpt[2]);

Tell me about...

Programming Overview of SDS™ (Solutions Development System™)