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 .
20 #ifndef INCLUDED_BASEGFX_SOURCE_WORKBENCH_BEZIERCLIP_HXX
21 #define INCLUDED_BASEGFX_SOURCE_WORKBENCH_BEZIERCLIP_HXX
27 typedef double value_type
;
28 Point2D( double _x
, double _y
) : x(_x
), y(_y
) {}
29 Point2D() : x(), y() {}
41 Point2D
& operator[]( int i
) { return reinterpret_cast<Point2D
*>(this)[i
]; }
42 const Point2D
& operator[]( int i
) const { return reinterpret_cast<const Point2D
*>(this)[i
]; }
47 // line L through p1 and p4 in normalized implicit form
52 // the upper and lower distance from this line
57 template <typename DataType
> DataType
calcLineDistance( const DataType
& a
,
66 typedef ::std::vector
< Point2D
> Polygon2D
;
68 /* little abs template */
69 template <typename NumType
> NumType
absval( NumType x
)
74 Polygon2D
convexHull( const Polygon2D
& rPoly
);
76 // TODO: find proper epsilon here (try ::std::numeric_limits<NumType>::epsilon()?)!
77 #define DBL_EPSILON 1.0e-100
79 /* little approximate comparisons */
80 template <typename NumType
> bool tolZero( NumType n
) { return fabs(n
) < DBL_EPSILON
; }
81 template <typename NumType
> bool tolEqual( NumType n1
, NumType n2
) { return tolZero(n1
-n2
); }
82 template <typename NumType
> bool tolLessEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
<n2
; }
83 template <typename NumType
> bool tolGreaterEqual( NumType n1
, NumType n2
) { return tolEqual(n1
,n2
) || n1
>n2
; }
85 #endif // INCLUDED_BASEGFX_SOURCE_WORKBENCH_BEZIERCLIP_HXX
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */