![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
![]() |
Thanks to your suggestions of some weeks ago, now I'm able to control the view of my canvas. :-) Also with smooth animations. :-))
Now the question is: what are the proper values for the zoom parameter? I need to fit the view so a certain geographic sector is shown; I had initially wrote down some maths for computing the elevation of the camera, and that worked decently; but I see that the FlyToOrbitViewStateIterator only accepts a 'zoom' parameter. Now, after a few tries, it looks like my maths for the elevation works fine with the zoom too :-)) Is the zoom just an alias for the elevation?
__________________
-- Fabrizio Giudici, Ph.D. - Java Architect, Project Manager Tidalwave s.a.s. - "We make Java work. Everywhere." weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941 |
|
|
|
|
|
#2 |
|
WWJ Dev. Team
Join Date: May 2007
Posts: 449
![]() |
Hi Fabrizio,
When the view is looking straight down (pitch or tilt is zero), OrbitView's zoom will closely match its altitude. There is no guarantee however, that the two will be equivalent. Zoom is the distance between eye and the "look-at" point on the surface, whereas altitude is the eye height above sea level. If you only need an estimate of altitude, and your view will be looking straight down, then zoom can approximate the value you need. FlyToOrbitViewStateIterator only operates on the independent attributes of OrbitView: * look-at latitude & longitude * heading * pitch * zoom This is the set of attributes (as they are currently defined) that can be changed without affecting one another. Changing altitude, for example, will in most cases also affect look-at latitude & longitude, and zoom (and in some edge cases heading and pitch). I encourage you to write your own OrbitViewStateIterator if you find that the default supplied with WorldWind doesn't suit your needs. There's no tutorial yet, but a short tour of the viewing code, especially BasicOrbitViewAnimator.java and FlyToOrbitViewStateIterator.java should get you on the right track. Thanks, Dave Collins |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
![]() |
Thank you Dave.
Indeed zoom, according to the definition you gave, is just what I need, as I must control things in relationship with the "look-at" point.
__________________
-- Fabrizio Giudici, Ph.D. - Java Architect, Project Manager Tidalwave s.a.s. - "We make Java work. Everywhere." weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941 |
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Nov 2006
Location: Mojave & Oxnard California
Posts: 2,623
![]() |
dcollins: "altitude is the eye height above sea level" - - Good.
With pitch of zero the zoom would be the distance to the terrain or distance Above Ground Level, AGL. This is the convention used by pilots, etc. WWJ often uses alt for AGL. If the terrain elevation is 5,000 ft (1524 meters) and the camera is 1,000 ft (305 m) above the terrain the alt should be 6,000 ft (1829 m) above sea level and not 1,000 ft (305 m). WW .net was the same way. |
|
|
|
|
|
#5 |
|
Member
Join Date: Oct 2007
Posts: 40
![]() |
What is the exact mathematical equation between:
* Altitude, which is view.getEyePosition().getElevation() * Zoom, view.getZoom() * Pitch angle, view.getPitch() * Elevation, view.getCenterPosition().getElevation() Some kind of Altitude = cosine(Pitch) * (Zoom + Elevation) ??? |
|
|
|
|
|
#6 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
The orbit view is defined as an eye always looking at a point (the center point) lying on the globe surface.
- Altitude is the eye altitude above sea level - Zoom is the distance in meter between the eye and the center point on the surface. - Pitch is the angle between the vertical (ellipsoid normal) at the center point and the eye forward vector - Elevation is the center point elevation - the terrain elevation the eye is looking at. Not sure this is answering your question though... |
|
|
|
|
|
#7 |
|
Member
Join Date: Oct 2007
Posts: 40
![]() |
Thank you Pat. I thought the same but something's wrong.
The equation should be: Altitude = Zoom * cosine(Pitch) + Elevation but I took a sample data altitude = 6380.466112825255 m zoom = 5789.086592250981 m elevation = 3902.9342137254084 m pitch = 64.68500279086172° head = 0.0° measured at latitude= 39.68381186667483° longitude= 44.30099387891051° As you can see the result is not equal to the altitude 5789.086592250981 * cosine(64.68500279086172) + 3902.9342137254084 = 2289.99847 m What could be the problem? |
|
|
|
|
|
#8 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
This is not the right formula - this one would measure the eye projected altitude at the vertical of the center point.
|
|
|
|
|
|
#9 |
|
Member
Join Date: Oct 2007
Posts: 40
![]() |
So we do not know the equation.
My aim is to double-click to fly from one position to another. I want the beginning altitude and the final altitude be equal. My code is: Code:
wwd.getInputHandler().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
OrbitView view = (OrbitView)wwd.getView();
final Position position = view.computePositionFromScreenPoint(e.getX(), e.getY());
Earth earth = ww3DAnimationView.getEarth();
Angle head = view.getHeading();
Angle pitch = view.getPitch();
double elevation = position.getElevation();
double altitude = 15000;//constant
double calculatedZoomForConstantAltiude = (altitude - elevation) / Math.cos(pitch.getRadians());
view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator(view, earth, position, head, pitch, calculatedZoomForConstantAltiude));
}
e.consume();
}
});
|
|
|
|
|
|
#10 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
You have to make a drawing showing the globe, the view center point and the eye to properly understand the geometry involved. Make sure the pitch angle is in the right place - between the vertical at the center point and the eye forward vector. A common misunderstanding is to think of the pitch as the angle between the forward vector and the vertical under the eye.
If what you want to achieve is a constant eye altitude above sea level, you may just adjust the zoom using the difference between the current center point elevation and the target center point elevation multiplied by the pitch cosine. Something like: cp1 is current view center point, cp2 is the target center point you clicked on. target zoom = current zoom + (cp2 elev - cp1 elev) * cosine(pitch) Note that in your code, view.computePositionFromScreenPoint will not account for terrain elevation - it intersects a line with the globe ellipsoid. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|