Cross-platform C SDK logo

Cross-platform C SDK

2D Segments

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Functions

Seg2Dseg2d (...)
V2Dseg2d_eval (...)
realseg2d_close_param (...)
realseg2d_point_sqdist (...)

Segments are fragments of a line between two points (Figure 1). After vectors, they are the most elementary geometric primitives.

Drawing of different line segments in the plane.
Figure 1: Segments in the plane.

seg2d ()

Create a 2d segment from its components.

Seg2Df
seg2df(const real32_t x0,
       const real32_t y0,
       const real32_t x1,
       const real32_t y1);

Seg2Dd
seg2dd(const real64_t x0,
       const real64_t y0,
       const real64_t x1,
       const real64_t y1);

Seg2D
Seg2D(const real x0,
      const real y0,
      const real x1,
      const real y1);
x0

X coordinate of the first point.

y0

Y coordinate of the first point.

x1

X coordinate of the second point.

y1

Y coordinate of the second point.

Return

The 2d segment.


seg2d_eval ()

Gets the point in the segment based on the parameter.

V2Df
seg2d_evalf(const Seg2Df *seg,
            const real32_t t);

V2Dd
seg2d_evald(const Seg2Dd *seg,
            const real64_t t);

V2D
Seg2D::eval(const Seg2D *seg,
            const real t);
seg

Segment.

t

Parameter.

Return

Point on the segment (or on the line that contains it).

Remarks

If t=0 it returns p0. If t=1 it returns p1. Values ​​between (0,1) points within the segment. Other values, points on the line that contains the segment.


seg2d_close_param ()

Gets the parameter of the segment closest to a given point.

real32_t
seg2d_close_paramf(const Seg2Df *seg,
                   const V2Df *pnt);

real64_t
seg2d_close_paramd(const Seg2Dd *seg,
                   const V2Dd *pnt);

real
Seg2D::close_param(const Seg2D *seg,
                   const V2D *pnt);
seg

Segment.

pnt

Point.

Return

Parameter. See seg2d_evalf.


seg2d_point_sqdist ()

Gets the squared distance from a point to the segment.

real32_t
seg2d_point_sqdistf(const Seg2Df *seg,
                    const V2Df *pnt,
                    real32_t *t);

real64_t
seg2d_point_sqdistd(const Seg2Dd *seg,
                    const V2Dd *pnt,
                    real64_t *t);

real
Seg2D::point_sqdist(const Seg2D *seg,
                    const V2D *pnt,
                    real *t);
seg

Segment.

pnt

Point.

t

Parameter on the line that contains the segment. See seg2d_close_paramf. It can be NULL if we don't need this value.

Return

Distance square.

❮ Back
Next ❯