1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
26 typedef double value_type
;
27 Point2D( double _x
, double _y
) : x(_x
), y(_y
) {}
28 Point2D() : x(), y() {}
40 Point2D
& operator[]( int i
) { return reinterpret_cast<Point2D
*>(this)[i
]; }
41 const Point2D
& operator[]( int i
) const { return reinterpret_cast<const Point2D
*>(this)[i
]; }
46 // line L through p1 and p4 in normalized implicit form
51 // the upper and lower distance from this line
56 template <typename DataType
> DataType
calcLineDistance( const DataType
& a
,
65 typedef std::vector
< Point2D
> Polygon2D
;
67 /* little abs template */
68 template <typename NumType
> NumType
absval( NumType x
)
73 Polygon2D
convexHull( const Polygon2D
& rPoly
);
75 // TODO: find proper epsilon here (try std::numeric_limits<NumType>::epsilon()?)!
76 constexpr auto DBL_EPSILON
= 1.0e-100;
78 /* little approximate comparisons */
79 template <typename NumType
> bool tolZero( NumType n
) { return fabs(n
) < DBL_EPSILON
; }
80 template <typename NumType
> bool tolEqual( NumType n1
, NumType n2
) { return tolZero(n1
-n2
); }
81 template <typename NumType
> bool tolLessEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
<n2
; }
82 template <typename NumType
> bool tolGreaterEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
>n2
; }
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */