0023663: Removing 2D viewer library
[occt.git] / src / Graphic2d / Graphic2d_Primitive.pxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19
20 #ifndef PRIMITIVE_PXX_INCLUDED
21 #define PRIMITIVE_PXX_INCLUDED
22
23 #define NEW_ANGLE(a)  { \
24 int quot = (int) (a/(2. * M_PI)); \
25         if (Abs(quot) >= 1) a = a - 2. * M_PI * quot; \
26 }
27
28 #define REALEPSILON()  (0.0001)
29
30 #define VALUE_OF_ANGLE(x,y,z)  { \
31 double a; \
32                 if (x > 0.) \
33                         if (x <= REALEPSILON ()) x = 0.; \
34                 if (x < 0.) \
35                         if (-x <= REALEPSILON ()) x = 0.; \
36                 if (y > 0.) \
37                         if (y <= REALEPSILON ()) y = 0.; \
38                 if (y < 0.) \
39                         if (-y <= REALEPSILON ()) y = 0.; \
40                 if (x == 0.) { \
41                         if (y > 0.) z = M_PI / 2.; \
42                         else z = - M_PI / 2.; \
43                 } \
44                 if (y == 0.) { \
45                         if (x > 0.) z = 0.; \
46                         else z = M_PI; \
47                 } \
48                 if ((x < 0.) && (y > 0.)) { \
49                         a = acos (x); \
50                         if ((a >= M_PI / 2.-REALEPSILON ()) && \
51                             (a <= M_PI + REALEPSILON ())) \
52                                 z = a; \
53                         else \
54                                 z = - a; \
55                 } \
56                 if ((x >= 0.) && (y > 0.)) { \
57                         a = acos (x); \
58                         if ((a >= 0.) && \
59                             (a <= M_PI / 2. + REALEPSILON ())) \
60                                 z = a; \
61                         else \
62                                 z = - a; \
63                 } \
64                 if ((x < 0.) && (y < 0.)) { \
65                         a = acos (x); \
66                         z = - a; \
67                 } \
68                 if ((x > 0.) && (y < 0.)) { \
69                         a = acos (x); \
70                         if ((a >= 0.) && \
71                             (a <= M_PI / 2. + REALEPSILON ())) \
72                                 z = - a; \
73                         else \
74                                 z = a; \
75                 } \
76 }
77
78 #define XROTATE(x,y) ((x)*cosa - (y)*sina)
79 #define YROTATE(x,y) ((y)*cosa + (x)*sina)
80
81 #endif