Re: Z-range [message #18179] |
Tue, 14 December 1999 00:00 |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Xiaoming XU wrote:
> Hi,
>
> how can I set the Z range in the scale of x, y when use surface?
> In other words, how the x,y,z be plotted in the same scale?
>
> Thanks!
>
> Xu
Hello,
I have used the routine AxisScaling (below) with object graphics. I
think you might be able to use it to set up the position coordinates
that you can specify as a keyword to surface.
Try something like the following:
; set [XYZ]range values to the min/max of data range you would like to
see
XRange = [0,100]
Yrange = [50, 100]
Zrange = [20, 50]
; set [XYZ]position you would like the axes to occupy (of the graphics
space) if
; they were all the same data range... these maybe changed by the
scaling process
Xposition = [0.1, 0.9]
Yposition = [0.1,0.9]
Zposition = [0.1, 0.9]
;assuming that the xrange or yrange is the largest of all three...
scale the position of the smaller
XYScaling = AxisScaling(Xrange,Yrange, PositionA = Xposition, PositionB
= Yposition)
Print, 'XYScaling:', XYScaling
print, 'Xposition:', Xposition
print,'Yposition:', Yposition
;Using larger of above scales as a baseline, scale the z axis
Case XYScaling[0] of
1.0 : Zscaling = AxisScaling(Xrange, Zrange, PositionA = Xposition,
PositionB = Zposition)
Else: Zscaling = AxisScaling(Yrange,Zrange, PositionA = Yposition,
PositionB = Zposition)
EndCase
Print,'Zscaling:',Zscaling
Print, 'Zposition:',Zposition
;now set up the postion keyword for 3d graphics
Position = [Xposition[0], Yposition[0], Zposition[0], Xposition[1],
Yposition[1], Zposition[1]]
Please let me know if it works for you.
Ben
--
Ben Tupper
Pemaquid River Company
248 Lower Round Pond Road
POB 106
Bristol, ME 04539
Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
;+
; NAME:
; AxisScaling
;
; PURPOSE:
; This function returns a two element scaling vector given two data
ranges. It is useful
; for determining relative axis lengths.
;
; CATEGORY:
; Miscellaneous.
;
; CALLING SEQUENCE:
;
; result =AxisScaling( RangeA,RangeB)
;
; INPUTS:
; RangeA and RangeB are two element vectors of min/max values for each
data range.
;
; OPTIONAL INPUTS:
; None.
;
; KEYWORD PARAMETERS:
; PositionA, PositionB Two element vectors specifying the location of
each axis (default is [0,1])
; on output, one of the Position Vectors is adjusted to reflect the
scale of ranges.
;
; OUTPUTS:
; A two element floating point array is returned. Each element is the
relative
; scaling factor for Ranges A and B respectively.
;
; OPTIONAL OUTPUTS:
; None.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None known.
;
; RESTRICTIONS:
; None known.
;
; EXAMPLE:
; Here's the steps to use to scale the axes used for displaying along
600x480 image
; into a dataspace of -.5 to .5 in each direction.
;IDL> RangeA = [0,639]
;IDL> RangeB = [0,479]
;IDL> PositionA = [-0.5,0.5]
;IDL> PositionB = [-0.5,0.5]
;IDL>
Print,AxisScaling(RangeA,RangeB,PositionA=PositionA,Position B=PositionB)
; 1.00000 0.749609 ; Note that RangeA is larger so it is scaled
at 1.0
;IDL> print,PositionA
; -0.500000 0.500000 ; Note that PositionA is unchanged since
RangeA is larger
;IDL> Print,PositionB
; -0.500000 0.249609 ;Note The PositionB is changed...
; ;its length is 74.9% of axisA's length.
;
; Then go on to normalize the coordinates using David Fanning's
procedure
;
;ScaleA = Normalize(RangeA, Position = PositionA)
;ScaleB = Normalize(RangeB,Position = PositionB)
;
; MODIFICATION HISTORY:
; Written by: Ben Tupper, 17 SEP 1999
; Pemaquid River Company
; email pemaquidriver@tidewater.net
; tel: (207) 563 - 1048
; 248 Lower Round Pond Road
; POB 106
; Bristol, ME 04539-0106
;
; 29 SEP 99 Added Aposition,Bposition keywords so new postion coords
can be calculated.
; Oct 1999 Changed its name to AxisScalig from RelativeScaling to
maintain
; consistency with AxisText, AxisLocate, etc. Cleaned up the
documentation.
;
;
;-
FUNCTION AxisScaling, RangeA, RangeB, PositionA=PositionA, PositionB =
PositionB
If n_elements(PositionA) EQ 0 Then PositionA = [0,1.]
If n_elements(PositionB) EQ 0 Then PositionB = [0,1.]
DiffA = RangeA[1] - RangeA[0]
DiffB = RangeB[1] - RangeB[0]
Ratio = DiffA/float(DiffB)
Case 1 of
Ratio GE 1: BEGIN
Scaling = [1.0,1./Ratio]
;Psition A is unchanged
PositionB = [PositionB[0],
((PositionB[1]-PositionB[0])*Scaling[1])+PositionB[0] ]
END
Ratio LT 1: BEGIN
Scaling = [Ratio,1.0]
PositionA = [PositionA[0], ((PositionA[1]-PositionA[0])*Scaling[0]
)+PositionA[0] ]
;PositionB is unchanged
END
Endcase
Return, Scaling
End
|
|
|