CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GeEllipArc.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25#ifndef __OD_GE_ELLIP_ARC__
26#define __OD_GE_ELLIP_ARC__
27
28#include "OdRound.h"
29
35namespace OdGeEllipArc
36{
42 inline double calibrateAngle(double val, double input)
43 {
44 if (input > val)
45 {
46 if ((input - val) < OdaPI)
47 return val;
48 else
49 return val + OdRound((input - val) / Oda2PI) * Oda2PI;
50 }
51 else
52 {
53 if ((val - input) < OdaPI)
54 return val;
55 else
56 return val - OdRound((val - input) / Oda2PI) * Oda2PI;
57 }
58 }
59
74 inline double angleFromParam(
75 double param,
76 double radiusRatio)
77 {
78 if (OdZero(param, 1e-7))
79 return 0;
80 if (OdZero(param - Oda2PI, 1e-7))
81 return Oda2PI;
82
83 return calibrateAngle(OD_ATAN2(radiusRatio * sin(param), cos(param)), param);
84 }
85
101 inline double paramFromAngle(
102 double angle,
103 double radiusRatio)
104 {
105 if (OdZero(angle, 1e-12))
106 return 0;
107 if (OdZero(angle - Oda2PI, 1e-12))
108 return Oda2PI;
109
110 return calibrateAngle(OD_ATAN2(sin(angle), radiusRatio * cos(angle)), angle);
111 }
112}
113
114#endif // __OD_GE_ELLIP_ARC__
#define OD_ATAN2(y, x)
Definition: DebugStuff.h:281
double OdRound(double a)
Definition: OdRound.h:34
#define OdaPI
Definition: OdaCommon.h:51
#define Oda2PI
Definition: OdaCommon.h:57
bool OdZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:532
double calibrateAngle(double val, double input)
Definition: GeEllipArc.h:42
double angleFromParam(double param, double radiusRatio)
Definition: GeEllipArc.h:74
double paramFromAngle(double angle, double radiusRatio)
Definition: GeEllipArc.h:101