-
Notifications
You must be signed in to change notification settings - Fork 1
/
vtkGeoSphereTransform.cxx
114 lines (96 loc) · 3.17 KB
/
vtkGeoSphereTransform.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGeoSphereTransform.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
#include "vtkGeoSphereTransform.h"
#include "vtkDoubleArray.h"
#include "vtkGeoMath.h"
#include "vtkGlobeSource.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
vtkStandardNewMacro(vtkGeoSphereTransform);
vtkGeoSphereTransform::vtkGeoSphereTransform()
{
this->ToRectangular = true;
this->BaseAltitude = 0.0;
}
vtkGeoSphereTransform::~vtkGeoSphereTransform()
{
}
void vtkGeoSphereTransform::PrintSelf( ostream& os, vtkIndent indent )
{
this->Superclass::PrintSelf(os, indent);
os << indent << "ToRectangular: " << this->ToRectangular << endl;
os << indent << "BaseAltitude: " << this->BaseAltitude << endl;
}
void vtkGeoSphereTransform::Inverse()
{
this->ToRectangular = !this->ToRectangular;
this->Modified();
}
void vtkGeoSphereTransform::InternalTransformPoint( const float in[3], float out[3] )
{
double ind[3];
double oud[3];
int i;
for ( i = 0; i < 3; ++ i )
ind[i] = in[i];
this->InternalTransformPoint( ind, oud );
for ( i = 0; i < 3; ++ i )
out[i] = static_cast<float>(oud[i]);
}
void vtkGeoSphereTransform::InternalTransformPoint( const double in[3], double out[3] )
{
if ( this->ToRectangular )
{
vtkGlobeSource::ComputeGlobePoint(
in[0], in[1], vtkGeoMath::EarthRadiusMeters() + in[2] + this->BaseAltitude, out);
}
else
{
vtkGlobeSource::ComputeLatitudeLongitude(const_cast<double*>(in), out[0], out[1]);
out[2] = vtkMath::Norm(in) - vtkGeoMath::EarthRadiusMeters() - this->BaseAltitude;
}
}
void vtkGeoSphereTransform::InternalTransformDerivative( const float in[3], float out[3], float derivative[3][3] )
{
double ind[3];
double oud[3];
double drd[3][3];
int i;
for ( i = 0; i < 3; ++ i )
ind[i] = in[i];
this->InternalTransformDerivative( ind, oud, drd );
for ( i = 0; i < 3; ++ i )
{
out[i] = static_cast<float>(oud[i]);
for ( int j = 0; j < 3; ++ j )
{
derivative[i][j] = drd[i][j];
}
}
}
void vtkGeoSphereTransform::InternalTransformDerivative( const double in[3], double out[3], double derivative[3][3] )
{
// FIXME: Compute derivatives here
(void) in;
(void) out;
(void) derivative;
}
vtkAbstractTransform* vtkGeoSphereTransform::MakeTransform()
{
vtkGeoSphereTransform* geoTrans = vtkGeoSphereTransform::New();
return geoTrans;
}