Graphviz
14.1.2~dev.20260118.1035
Loading...
Searching...
No Matches
makecw.c
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (c) 2011 AT&T Intellectual Property
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* https://www.eclipse.org/legal/epl-v10.html
7
*
8
* Contributors: Details at https://graphviz.org
9
*************************************************************************/
10
11
/*
12
* Force the vertices of a polygon to be in CW order.
13
*
14
* Works for polygons with concavities.
15
* Does not work for twisted polygons.
16
*
17
* ellson@graphviz.org October 2nd, 1996
18
*/
19
20
#include "config.h"
21
22
#include "
makecw.h
"
23
#include <
pathplan/pathutil.h
>
24
#include <stddef.h>
25
26
void
make_CW
(
Ppoly_t
*
poly
)
27
{
28
Ppoint_t
*P;
29
Ppoint_t
tP;
30
double
area = 0.0;
31
32
P =
poly
->ps;
33
const
size_t
n =
poly
->pn;
34
/* points or lines don't have a rotation */
35
if
(n > 2) {
36
/* check CW or CCW by computing (twice the) area of poly */
37
for
(
size_t
i = 1; i < n - 1; i++) {
38
area +=
area2
(P[0], P[i + 1], P[i]);
39
}
40
/* if the area is -ve then the rotation needs to be reversed */
41
/* the starting point is left unchanged */
42
if
(area < 0.0) {
43
for
(
size_t
i = 1, j = n - 1; i < 1 + n / 2; i++, j--) {
44
tP = P[i];
45
P[i] = P[j];
46
P[j] = tP;
47
}
48
}
49
}
50
}
make_CW
void make_CW(Ppoly_t *poly)
Definition
makecw.c:26
makecw.h
pathutil.h
area2
PATHUTIL_API COORD area2(Ppoint_t, Ppoint_t, Ppoint_t)
Definition
visibility.c:46
Ppoly_t
Definition
pathgeom.h:45
Pxy_t
Definition
pathgeom.h:37
poly_s
Definition
tclpathplan.c:51
tclpkg
tclpathplan
makecw.c
Generated by
1.9.8