how to determine visible data range?

Tomas Pluskal pluskal at oist.jp
Wed Jun 21 01:36:33 MDT 2006


Thank you for reply.
If I understand it right, I can get [X:Y] coordinates of the point on  
the screen by finding an intersection of XY plane with the VisADRay  
that I get from MouseBehavior.findRay()?

I tried it with this code to get the [X:Y] coordinates of a point  
which is in the screen center:

             ScalarMap rtMap = (ScalarMap) display.getMapVector().get 
(0);
             ScalarMap mzMap = (ScalarMap) display.getMapVector().get 
(1);

             int width = display.getComponent().getWidth();
             int height = display.getComponent().getHeight();

             VisADRay centerRay = display.getMouseBehavior().findRay 
(width / 2, height / 2 );

             Point3d point = new Point3d(centerRay.position);
             Vector3d vec = new Vector3d(centerRay.vector);
             Point3d intersectionWithXY = new Point3d(vec);
             intersectionWithXY.scale(-1 * (centerRay.position[2] /  
centerRay.vector[2]));
             intersectionWithXY.add(point);

             float[] xValue = { (float) intersectionWithXY.x };
             float[] yValue = { (float) intersectionWithXY.y };
             xValue = rtMap.inverseScaleValues(xValue);
             yValue = mzMap.inverseScaleValues(yValue);

             System.out.println("center: X " + xValue[0]  + " Y " +  
yValue[0] + " point "+ point + " vector " + vec + " intersection with  
XY " + intersectionWithXY);


My X axis is time in seconds (range 0-600). Y axis is mass, in range  
200-700.
I have places a screenshot on our website - here I'm viewing  
approximately the corner of XY plane (time = 0, mass = 200)
http://www.irp.oist.jp/g0/visad.png

But the result I get is not very meaningful, on the console I see  
time = -107, mass = 126:
center: X -107.90359 Y 126.864235 point (-0.90017273539354,  
-0.8998164683151662, -1.3662550798389146) vector  
(0.30768277084795087, 0.2632214900056231, -0.9143553793370206)  
intersection with XY (-1.359920835694245, -1.2931292939078902, 0.0)

Is there anything wrong in my approach?


Tomas


On Jun 20, 2006, at 11:00 PM, Don Murray wrote:

>
> We do this by using a projection listener to listen for
> changes and then sampling the screen at the corners to determine
> the XY bounds.  You can use the MouseBehavior.findRay(x,y) method
> to figure out what the VisAD X/Y/Z values are at screen xy  
> coordinates.
> Use DisplayImpl.getComponent().getBounds() to figure out how large
> your canvas is and then sample at the 4 corners.  Then for
> each point, use the ScalarMap.inverseScaleValues() method
> to convert the x and y values to the scalar values of
> the map.  That should give you the limits of the visible
> portion of your screen that you can use for resampling.
> If you have a display side coordinate system (e.g. map projection),
> your mappings are not necessarily linear.  In that case, we sample
> at 9 points (3 across the top, middle and bottom) on the screen
> to get a more representative bounds.
>

=========================================
Tomas Pluskal
G0 Cell Unit, Initial Research Project
Okinawa Institute of Science and Technology
12-22 Suzaki, Uruma-shi, Okinawa 904-2234, JAPAN
TEL:  +81-98-921-3966




-------------- next part --------------



More information about the visad mailing list