[vtkusers] Transform a disc from center of earth to surface
Donny Zimmerman
donny.zimmerman at willowpointsoftware.com
Fri Dec 30 22:11:46 EST 2011
I am having trouble figuring out how to transform my 2d disc object to a
point and perpendicular to a vector.
I am plotting a weather radar which basically is a bunch of polygons onto a
rendering of the earth (vtkGlobeSource).
The world coordinates orgin is the center of the earth. The vector from the
origin to the North Pole is the z axis, the vector from the origin to 0
degrees longitude is up the y axis.
I am drawing the radar using local coordinates where the center of the radar
is at (0, 0, 0).
I need to translate and rotate the radar plot to the surface of the earth at
a known radar location.
The two variables I know are the point on the globe and the vector from the
origin (center of earth) to the radar point.
I have tried to calculate the angle of rotation for each axis but I am not
getting the desired results.
Here is a code snippet:
//Get World Point Of North Pole
vtkGlobeSource::ComputeGlobePoint(0, 90.0,
vtkGeoMath::EarthRadiusMeters(),
radwp);
double np[3];
np[0] = radwp[0];
np[1] = radwp[1];
np[2] = radwp[2];
vtkMath::Normalize(np);
//m_wpx, m_wpy, and m_wpz are the radar site coordinates
double px[3];
px[0] = m_wpx;
px[1] = 0;
px[2] = m_wpz;
vtkMath::Normalize(px);
double yangle = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(px,
np)));
px[0] = 0;
px[1] = m_wpy;
px[2] = m_wpz;
vtkMath::Normalize(px);
double xangle = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(px,
np)));
//Get World Point Of Equator at 0 Deg Longitude
vtkGlobeSource::ComputeGlobePoint(0, 0,
vtkGeoMath::EarthRadiusMeters(),
radwp);
double eq[3];
eq[0] = radwp[0];
eq[1] = radwp[1];
eq[2] = radwp[2];
vtkMath::Normalize(eq);
double pz[3];
pz[0] = m_wpx;
pz[1] = m_wpy;
pz[2] = 0;
vtkMath::Normalize(pz);
double zangle = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(pz,
eq)));
vtkSmartPointer<vtkTransformPolyDataFilter> tf =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
tf->SetInput(polydata);
vtkSmartPointer<vtkTransform> xfm =
vtkSmartPointer<vtkTransform>::New();
xfm->Identity();
xfm->Translate(m_wpx, m_wpy, m_wpz);
xfm->RotateX(xangle);
xfm->RotateY(yangle);
// Need to subtract from 180 degrees to point top of radar to north
pole.
xfm->RotateZ(180.0 - zangle);
tf->SetTransform(xfm);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111230/3cac5dc6/attachment.htm>
More information about the vtkusers
mailing list