Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
VTK
VTK
Commits
47b2edd2
Commit
47b2edd2
authored
Nov 14, 2008
by
Philippe Pebay
Browse files
ENH: clean-up of old-style angle conversions.
parent
12a0b20c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Geovis/vtkCompassRepresentation.cxx
View file @
47b2edd2
...
...
@@ -44,7 +44,7 @@
#include <sstream>
vtkCxxRevisionMacro
(
vtkCompassRepresentation
,
"1.
1
"
);
vtkCxxRevisionMacro
(
vtkCompassRepresentation
,
"1.
2
"
);
vtkStandardNewMacro
(
vtkCompassRepresentation
);
//----------------------------------------------------------------------
...
...
@@ -232,13 +232,13 @@ void vtkCompassRepresentation::BuildRing()
{
this
->
Points
->
SetPoint
(
i
,
this
->
OuterRadius
*
cos
(
(
i
+
10
)
*
10
*
vtkMath
::
DegreesToRadians
()
),
this
->
OuterRadius
*
sin
(
(
i
+
10
)
*
10
*
vtkMath
::
DegreesToRadians
()
),
this
->
OuterRadius
*
cos
(
vtkMath
::
RadiansFromDegrees
(
10.
*
(
i
+
10
)
)
),
this
->
OuterRadius
*
sin
(
vtkMath
::
RadiansFromDegrees
(
10.
*
(
i
+
10
)
)
),
0.0
);
this
->
Points
->
SetPoint
(
i
+
35
,
this
->
InnerRadius
*
cos
(
(
i
+
10
)
*
10
*
vtkMath
::
DegreesToRadians
()
),
this
->
InnerRadius
*
sin
(
(
i
+
10
)
*
10
*
vtkMath
::
DegreesToRadians
()
),
this
->
InnerRadius
*
cos
(
vtkMath
::
RadiansFromDegrees
(
10.
*
(
i
+
10
)
)
),
this
->
InnerRadius
*
sin
(
vtkMath
::
RadiansFromDegrees
(
10.
*
(
i
+
10
)
)
),
0.0
);
}
// add the WSE points
...
...
@@ -370,37 +370,37 @@ void vtkCompassRepresentation::BuildRepresentation()
int
center
[
2
];
double
rsize
;
this
->
GetCenterAndUnitRadius
(
center
,
rsize
);
this
->
GetCenterAndUnitRadius
(
center
,
rsize
);
while
(
this
->
Heading
<
0
)
while
(
this
->
Heading
<
0
)
{
this
->
Heading
+=
1
;
}
while
(
this
->
Heading
>
1
)
while
(
this
->
Heading
>
1
)
{
this
->
Heading
-=
1
;
}
double
angle
=
this
->
Heading
*
2.0
*
vtkMath
::
Pi
();
double
angle
=
this
->
Heading
*
2.0
*
vtkMath
::
Pi
();
this
->
XForm
->
Translate
(
center
[
0
],
center
[
1
],
0.0
)
;
this
->
XForm
->
Scale
(
rsize
,
rsize
,
1.0
);
this
->
XForm
->
RotateZ
(
angle
*
vtkMath
::
RadiansToDegrees
()
);
this
->
XForm
->
Translate
(
center
[
0
],
center
[
1
],
0.0
)
;
this
->
XForm
->
Scale
(
rsize
,
rsize
,
1.0
);
this
->
XForm
->
RotateZ
(
vtkMath
::
DegreesFromRadians
(
angle
)
);
this
->
LabelActor
->
SetPosition
(
center
[
0
]
+
rsize
*
cos
(
angle
+
vtkMath
::
Pi
()
/
2.0
)
*
this
->
InnerRadius
,
center
[
1
]
+
rsize
*
sin
(
angle
+
vtkMath
::
Pi
()
/
2.0
)
*
this
->
InnerRadius
);
(
center
[
0
]
+
rsize
*
cos
(
angle
+
vtkMath
::
Pi
()
/
2.0
)
*
this
->
InnerRadius
,
center
[
1
]
+
rsize
*
sin
(
angle
+
vtkMath
::
Pi
()
/
2.0
)
*
this
->
InnerRadius
);
double
fsize
=
1.4
*
rsize
*
this
->
InnerRadius
*
sin
(
vtkMath
::
RadiansFromDegrees
(
18.
)
);
double
fsize
=
1.4
*
rsize
*
this
->
InnerRadius
*
sin
(
18
*
vtkMath
::
DegreesToRadians
());
this
->
LabelActor
->
SetOrientation
(
angle
*
vtkMath
::
RadiansToDegrees
());
this
->
LabelProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
));
this
->
LabelActor
->
SetOrientation
(
vtkMath
::
DegreesFromRadians
(
angle
)
);
this
->
LabelProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
)
);
if
(
rsize
>
40
)
{
vtkstd
::
ostringstream
out
;
out
.
setf
(
ios
::
fixed
);
out
.
setf
(
ios
::
fixed
);
out
.
precision
(
0
);
out
<<
"Distance: "
;
...
...
@@ -415,14 +415,14 @@ void vtkCompassRepresentation::BuildRepresentation()
out
<<
"
\n
Tilt: "
<<
this
->
Tilt
;
out
<<
"
\n
Heading: "
<<
angle
*
vtkMath
::
RadiansToDegrees
(
);
out
<<
"
\n
Heading: "
<<
vtkMath
::
DegreesFromRadians
(
angle
);
this
->
LabelProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
*
0.8
)
);
this
->
StatusProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
*
0.9
)
);
this
->
StatusActor
->
SetInput
(
out
.
str
().
c_str
());
this
->
LabelProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
*
0.8
)
);
this
->
StatusProperty
->
SetFontSize
(
static_cast
<
int
>
(
fsize
*
0.9
)
);
this
->
StatusActor
->
SetInput
(
out
.
str
().
c_str
()
);
this
->
StatusActor
->
SetPosition
(
center
[
0
]
-
rsize
*
2.0
,
center
[
1
]
+
rsize
);
(
center
[
0
]
-
rsize
*
2.0
,
center
[
1
]
+
rsize
);
}
else
{
...
...
@@ -431,26 +431,26 @@ void vtkCompassRepresentation::BuildRepresentation()
// adjust the slider as well
this
->
TiltRepresentation
->
GetPoint1Coordinate
()
->
SetValue
(
center
[
0
]
-
rsize
*
1.5
,
center
[
1
]
-
rsize
,
0.0
);
SetValue
(
center
[
0
]
-
rsize
*
1.5
,
center
[
1
]
-
rsize
,
0.0
);
this
->
TiltRepresentation
->
GetPoint2Coordinate
()
->
SetValue
(
center
[
0
]
-
rsize
*
1.2
,
center
[
1
]
+
rsize
,
0.0
);
SetValue
(
center
[
0
]
-
rsize
*
1.2
,
center
[
1
]
+
rsize
,
0.0
);
this
->
TiltRepresentation
->
Modified
();
this
->
TiltRepresentation
->
BuildRepresentation
();
// adjust the slider as well
this
->
DistanceRepresentation
->
GetPoint1Coordinate
()
->
SetValue
(
center
[
0
]
-
rsize
*
1.9
,
center
[
1
]
-
rsize
,
0.0
);
SetValue
(
center
[
0
]
-
rsize
*
1.9
,
center
[
1
]
-
rsize
,
0.0
);
this
->
DistanceRepresentation
->
GetPoint2Coordinate
()
->
SetValue
(
center
[
0
]
-
rsize
*
1.6
,
center
[
1
]
+
rsize
,
0.0
);
SetValue
(
center
[
0
]
-
rsize
*
1.6
,
center
[
1
]
+
rsize
,
0.0
);
this
->
DistanceRepresentation
->
Modified
();
this
->
DistanceRepresentation
->
BuildRepresentation
();
int
*
renSize
=
this
->
Renderer
->
GetSize
();
vtkUnsignedCharArray
*
colors
=
vtkUnsignedCharArray
::
SafeDownCast
(
this
->
BackdropMapper
->
GetInput
()
->
GetPointData
()
->
GetScalars
());
(
this
->
BackdropMapper
->
GetInput
()
->
GetPointData
()
->
GetScalars
()
);
unsigned
char
color
[
4
];
color
[
0
]
=
0
;
color
[
1
]
=
0
;
...
...
@@ -458,21 +458,21 @@ void vtkCompassRepresentation::BuildRepresentation()
vtkPoints
*
pts
=
this
->
BackdropMapper
->
GetInput
()
->
GetPoints
();
pts
->
SetPoint
(
1
,
renSize
[
0
],
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
2
,
renSize
[
0
],
renSize
[
1
],
0
);
pts
->
SetPoint
(
1
,
renSize
[
0
],
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
2
,
renSize
[
0
],
renSize
[
1
],
0
);
if
(
this
->
HighlightState
)
{
pts
->
SetPoint
(
0
,
center
[
0
]
-
rsize
*
5.0
,
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
3
,
center
[
0
]
-
rsize
*
5.0
,
renSize
[
1
],
0
);
pts
->
SetPoint
(
0
,
center
[
0
]
-
rsize
*
5.0
,
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
3
,
center
[
0
]
-
rsize
*
5.0
,
renSize
[
1
],
0
);
color
[
3
]
=
80
;
colors
->
SetTupleValue
(
1
,
color
);
}
else
{
pts
->
SetPoint
(
0
,
center
[
0
]
-
rsize
*
3.0
,
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
3
,
center
[
0
]
-
rsize
*
3.0
,
renSize
[
1
],
0
);
pts
->
SetPoint
(
0
,
center
[
0
]
-
rsize
*
3.0
,
center
[
1
]
-
rsize
*
1.1
,
0
);
pts
->
SetPoint
(
3
,
center
[
0
]
-
rsize
*
3.0
,
renSize
[
1
],
0
);
color
[
3
]
=
0
;
colors
->
SetTupleValue
(
1
,
color
);
colors
->
SetTupleValue
(
1
,
color
);
}
pts
->
Modified
();
colors
->
Modified
();
...
...
Geovis/vtkGeoAdaptiveArcs.cxx
View file @
47b2edd2
...
...
@@ -39,7 +39,7 @@
#include <vtksys/stl/map>
using
vtksys_stl
::
map
;
vtkCxxRevisionMacro
(
vtkGeoAdaptiveArcs
,
"1.
6
"
);
vtkCxxRevisionMacro
(
vtkGeoAdaptiveArcs
,
"1.
7
"
);
vtkStandardNewMacro
(
vtkGeoAdaptiveArcs
);
//-------------------------------------------------------------------------
...
...
@@ -201,11 +201,11 @@ int vtkGeoAdaptiveArcs::RequestData(
lastPointTooClose
=
false
;
// Don't draw lines off the current screen.
double
distFromCenterApprox
=
acos
(
curVec
[
0
]
*
cameraDir
[
0
]
+
curVec
[
1
]
*
cameraDir
[
1
]
+
curVec
[
2
]
*
cameraDir
[
2
])
*
vtkMath
::
RadiansToDegrees
(
)
/
viewAngle
*
renSize
[
1
];
double
distFromCenterApprox
=
vtkMath
::
DegreesFromRadians
(
acos
(
curVec
[
0
]
*
cameraDir
[
0
]
+
curVec
[
1
]
*
cameraDir
[
1
]
+
curVec
[
2
]
*
cameraDir
[
2
]
)
)
/
viewAngle
*
renSize
[
1
];
if
(
distFromCenterApprox
>
maxDist
)
{
// If both last point and this point are offscreen, skip
...
...
@@ -229,11 +229,11 @@ int vtkGeoAdaptiveArcs::RequestData(
continue
;
}
double
distApprox
=
acos
(
lastVec
[
0
]
*
curVec
[
0
]
+
lastVec
[
1
]
*
curVec
[
1
]
+
lastVec
[
2
]
*
curVec
[
2
])
*
vtkMath
::
RadiansToDegrees
(
)
/
viewAngle
*
renSize
[
1
];
double
distApprox
=
vtkMath
::
DegreesFromRadians
(
acos
(
lastVec
[
0
]
*
curVec
[
0
]
+
lastVec
[
1
]
*
curVec
[
1
]
+
lastVec
[
2
]
*
curVec
[
2
]
)
)
/
viewAngle
*
renSize
[
1
];
// If the points are too close, skip over it to the next point.
if
(
distApprox
<
this
->
MinimumPixelSeparation
)
...
...
Geovis/vtkGeoCamera.cxx
View file @
47b2edd2
...
...
@@ -28,7 +28,7 @@
#define VTK_EARTH_RADIUS_METERS 6356750.0
vtkCxxRevisionMacro
(
vtkGeoCamera
,
"1.1
0
"
);
vtkCxxRevisionMacro
(
vtkGeoCamera
,
"1.1
1
"
);
vtkStandardNewMacro
(
vtkGeoCamera
);
...
...
@@ -318,7 +318,7 @@ void vtkGeoCamera::UpdateVTKCamera()
double
dotProd
=
vtkMath
::
Dot
(
northProj
,
upProj
);
double
crossProd
[
3
];
vtkMath
::
Cross
(
northProj
,
upProj
,
crossProd
);
this
->
Heading
=
asin
(
vtkMath
::
Norm
(
crossProd
))
*
vtkMath
::
RadiansToDegrees
(
);
this
->
Heading
=
vtkMath
::
DegreesFromRadians
(
asin
(
vtkMath
::
Norm
(
crossProd
)
)
);
if
(
dotProd
<
0
)
{
this
->
Heading
=
180.0
-
this
->
Heading
;
...
...
@@ -333,10 +333,9 @@ void vtkGeoCamera::UpdateVTKCamera()
//-----------------------------------------------------------------------------
void
vtkGeoCamera
::
InitializeNodeAnalysis
(
int
rendererSize
[
2
])
{
this
->
Aspect
[
1
]
=
tan
(
this
->
VTKCamera
->
GetViewAngle
()
*
vtkMath
::
DegreesToRadians
()
*
0.5
);
this
->
Aspect
[
1
]
=
tan
(
vtkMath
::
RadiansFromDegrees
(
this
->
VTKCamera
->
GetViewAngle
()
)
*
0.5
);
this
->
Aspect
[
0
]
=
this
->
Aspect
[
1
]
*
rendererSize
[
0
]
/
static_cast
<
double
>
(
rendererSize
[
1
]);
/
static_cast
<
double
>
(
rendererSize
[
1
]
);
this
->
VTKCamera
->
GetViewPlaneNormal
(
this
->
ForwardNormal
);
this
->
ForwardNormal
[
0
]
=
-
this
->
ForwardNormal
[
0
];
...
...
Geovis/vtkGeoInteractorStyle.cxx
View file @
47b2edd2
...
...
@@ -45,7 +45,7 @@
#include <float.h>
vtkCxxRevisionMacro
(
vtkGeoInteractorStyle
,
"1.1
0
"
);
vtkCxxRevisionMacro
(
vtkGeoInteractorStyle
,
"1.1
1
"
);
vtkStandardNewMacro
(
vtkGeoInteractorStyle
);
#define VTK_EARTH_RADIUS_METERS 6356750.0
...
...
@@ -353,7 +353,7 @@ int vtkGeoInteractorStyle::ViewportToWorld(double xMouse,
dy
=
yMouse
-
size
[
1
]
*
0.5
;
double
angle
=
camera
->
GetViewAngle
();
double
tmp
=
tan
(
angle
*
0.5
*
vtkMath
::
DegreesToRadians
()
);
double
tmp
=
tan
(
vtkMath
::
RadiansFromDegrees
(
angle
)
*
0.5
);
vtkMath
::
Normalize
(
direction
);
// note the duplication of size[1] is intentional in the lines below
direction
[
0
]
=
direction
[
0
]
+
tmp
*
2.0
*
dx
*
right
[
0
]
/
size
[
1
]
...
...
@@ -378,8 +378,8 @@ void vtkGeoInteractorStyle::WorldToLongLat(double wx, double wy,
double
&
lon
,
double
&
lat
)
{
double
r
=
sqrt
(
wx
*
wx
+
wy
*
wy
+
wz
*
wz
);
lat
=
double
(
asin
(
wz
/
r
)
*
vtkMath
::
RadiansToDegrees
()
);
lon
=
double
(
atan2
(
wy
,
wx
)
*
vtkMath
::
RadiansToDegrees
(
)
-
90
);
lat
=
double
(
vtkMath
::
DegreesFromRadians
(
asin
(
wz
/
r
)
)
);
lon
=
double
(
vtkMath
::
DegreesFromRadians
(
atan2
(
wy
,
wx
)
)
-
90
.
);
}
void
vtkGeoInteractorStyle
::
ViewportToLongLat
(
double
x
,
double
y
,
...
...
@@ -619,7 +619,7 @@ void vtkGeoInteractorStyle::GetPanCenter(double &px, double &py)
vtkMath
::
Normalize
(
up
);
double
dx
,
dy
;
double
angle
=
camera
->
GetViewAngle
();
double
tmp
=
tan
(
angle
*
0.5
*
vtkMath
::
DegreesToRadians
()
);
double
tmp
=
tan
(
vtkMath
::
RadiansFromDegrees
(
angle
)
*
0.5
);
int
*
size
=
renderer
->
GetSize
();
tmp
=
tmp
*
2.0
/
size
[
1
];
vtkMath
::
Normalize
(
direction
);
...
...
Geovis/vtkGeoMath.cxx
View file @
47b2edd2
...
...
@@ -23,7 +23,7 @@
#include "vtkGeoMath.h"
#include "vtkMath.h"
vtkCxxRevisionMacro
(
vtkGeoMath
,
"1.
3
"
);
vtkCxxRevisionMacro
(
vtkGeoMath
,
"1.
4
"
);
vtkStandardNewMacro
(
vtkGeoMath
);
...
...
@@ -63,8 +63,8 @@ double vtkGeoMath::DistanceSquared(double pt0[3], double pt1[3])
//-----------------------------------------------------------------------------
void
vtkGeoMath
::
LongLatAltToRect
(
double
longLatAlt
[
3
],
double
rect
[
3
])
{
double
theta
=
longLatAlt
[
0
]
*
vtkMath
::
DegreesToRadians
(
);
double
phi
=
longLatAlt
[
1
]
*
vtkMath
::
DegreesToRadians
(
);
double
theta
=
vtkMath
::
RadiansFromDegrees
(
longLatAlt
[
0
]
);
double
phi
=
vtkMath
::
RadiansFromDegrees
(
longLatAlt
[
1
]
);
double
cosPhi
=
cos
(
phi
);
double
radius
=
vtkGeoMath
::
EarthRadiusMeters
()
+
longLatAlt
[
2
];
...
...
Geovis/vtkGeoTransform.cxx
View file @
47b2edd2
...
...
@@ -29,7 +29,7 @@
#include "vtk_libproj4.h"
vtkStandardNewMacro
(
vtkGeoTransform
);
vtkCxxRevisionMacro
(
vtkGeoTransform
,
"1.
2
"
);
vtkCxxRevisionMacro
(
vtkGeoTransform
,
"1.
3
"
);
vtkCxxSetObjectMacro
(
vtkGeoTransform
,
SourceProjection
,
vtkGeoProjection
);
vtkCxxSetObjectMacro
(
vtkGeoTransform
,
DestinationProjection
,
vtkGeoProjection
);
...
...
@@ -179,9 +179,9 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int
double
*
coord
=
x
;
for
(
vtkIdType
i
=
0
;
i
<
numPts
;
++
i
)
{
for
(
int
j
=
0
;
j
<
2
;
++
j
,
++
coord
)
for
(
int
j
=
0
;
j
<
2
;
++
j
,
++
coord
)
{
*
coord
*
=
vtkMath
::
DoubleDegreesToRadians
(
);
*
coord
=
vtkMath
::
RadiansFromDegrees
(
*
coord
);
}
coord
+=
delta
;
}
...
...
@@ -202,9 +202,9 @@ void vtkGeoTransform::InternalTransformPoints( double* x, vtkIdType numPts, int
double
*
coord
=
x
;
for
(
vtkIdType
i
=
0
;
i
<
numPts
;
++
i
)
{
for
(
int
j
=
0
;
j
<
2
;
++
j
,
++
coord
)
for
(
int
j
=
0
;
j
<
2
;
++
j
,
++
coord
)
{
*
coord
*
=
vtkMath
::
D
oubleRadiansToDegrees
(
);
*
coord
=
vtkMath
::
D
egreesFromRadians
(
*
coord
);
}
coord
+=
delta
;
}
...
...
Geovis/vtkGlobeSource.cxx
View file @
47b2edd2
...
...
@@ -37,7 +37,7 @@
#include <math.h>
vtkCxxRevisionMacro
(
vtkGlobeSource
,
"1.
7
"
);
vtkCxxRevisionMacro
(
vtkGlobeSource
,
"1.
8
"
);
vtkStandardNewMacro
(
vtkGlobeSource
);
// 0=NE, 1=SE, 2=SW, 3=NW
...
...
@@ -70,14 +70,14 @@ void vtkGlobeSource::ComputeGlobePoint(
// Lets keep this conversion code in a single place.
double
tmp
;
tmp
=
cos
(
phi
*
vtkMath
::
DegreesToRadians
()
);
n
[
0
]
=
-
tmp
*
sin
(
theta
*
vtkMath
::
DegreesToRadians
()
);
n
[
1
]
=
tmp
*
cos
(
theta
*
vtkMath
::
DegreesToRadians
()
);
n
[
2
]
=
sin
(
phi
*
vtkMath
::
DegreesToRadians
()
);
tmp
=
cos
(
vtkMath
::
RadiansFromDegrees
(
phi
)
);
n
[
0
]
=
-
tmp
*
sin
(
vtkMath
::
RadiansFromDegrees
(
theta
)
);
n
[
1
]
=
tmp
*
cos
(
vtkMath
::
RadiansFromDegrees
(
theta
)
);
n
[
2
]
=
sin
(
vtkMath
::
RadiansFromDegrees
(
phi
)
);
x
[
0
]
=
n
[
0
]
*
radius
;
x
[
1
]
=
n
[
1
]
*
radius
;
x
[
2
]
=
n
[
2
]
*
radius
;
x
[
0
]
=
n
[
0
]
*
radius
;
x
[
1
]
=
n
[
1
]
*
radius
;
x
[
2
]
=
n
[
2
]
*
radius
;
}
//----------------------------------------------------------------------------
...
...
@@ -95,8 +95,8 @@ void vtkGlobeSource::ComputeLatitudeLongitude(
{
theta
=
vtkMath
::
Pi
()
-
asin
(
x
[
1
]
/
S
);
}
phi
=
(
vtkMath
::
Pi
()
/
2.0
-
phi
)
*
vtkMath
::
RadiansToDegrees
(
);
theta
=
(
theta
-
vtkMath
::
Pi
()
/
2.0
)
*
vtkMath
::
RadiansToDegrees
(
);
phi
=
vtkMath
::
DegreesFromRadians
(
vtkMath
::
Pi
()
/
2.0
-
phi
);
theta
=
vtkMath
::
DegreesFromRadians
(
theta
-
vtkMath
::
Pi
()
/
2.0
);
}
//----------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment