Back to FabImage Library website
You are here: Start » Function Reference » Geometry 2D » Geometry 2D Spatial Transforms » SplitSegment
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
Splits a segment into several parts of equal length.
Syntax
C++
C#
void fil::SplitSegment ( const fil::Segment2D& inSegment, const int inCount, ftl::Array<fil::Segment2D>& outSegments )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
![]() |
inSegment | const Segment2D& | |||
![]() |
inCount | const int | 1 - ![]() |
2 | Number of segments after segment split |
![]() |
outSegments | Array<Segment2D>& |
Description
Filter computes outSegments using following formulas:
$$\mathbf {outSegments}[0].x_{begin} = \mathbf {inSegment}.x_{begin}$$
$$\mathbf {outSegments}[0].y_{begin} = \mathbf {inSegment}.y_{begin}$$
$$\mathbf {outSegments}[0].x_{end} = \mathbf {inSegment}.x_{begin} + \Delta x$$
$$\mathbf {outSegments}[0].y_{end} = \mathbf {inSegment}.y_{begin} + \Delta y$$
$$\mathbf {outSegments}[i].x_{begin} = \mathbf{outSegments}[i-1].x_{begin} + \Delta x $$
$$\mathbf {outSegments}[i].y_{begin} = \mathbf{outSegments}[i-1].y_{begin} + \Delta y $$
$$\mathbf {outSegments}[i].x_{end} = \mathbf{outSegments}[i-1].x_{end} + \Delta x $$
$$\mathbf {outSegments}[i].y_{end} = \mathbf{outSegments}[i-1].y_{end} + \Delta y $$
$$ i = 1, 2, .., \mathbf {inCount} - 1 $$
where
$$\Delta x = \frac {\mathbf{inSegment}.x_{end} - \mathbf{inSegment}.x_{begin} }{\mathbf{inCount} }$$
$$\Delta y = \frac {\mathbf{inSegment}.y_{end} - \mathbf{inSegment}.y_{begin} }{\mathbf{inCount} }$$
Examples
Assume segment described with two points:
Result will be as follows:
$$\mathbf {outSegments}[0]=\vec{P_1Q_1}=[1, 2] \quad \mathbf {outSegments}[1]=\vec{P_2Q_2}=[1, 2] \quad \mathbf {outSegments}[2]=\vec{P_3Q_3}=[1, 2]$$
- Start point P(0, 0)
- End point Q(3, 6).
Result will be as follows: