<<<<<<<<<<<<<<<<<

two_d(two_d) LYMB two_d(two_d)

NAME

two_d - interpolate values in a 2D space

DESCRIPTION

The two_d class allows the user to interpolate values from a set of (x,y,v) triples. Two different interpolation methods can be used: area coordinates or a simple distance-weighted average of all points.

SUPERCLASS

new_modeller

NOTE

"Current point" always refers to point defined by the current x and y instance variables.

INSTANCE VARIABLES

file is the filename used by the read! message when reading input data from a file.

x is the x coordinate of the current point.

y is the y coordinate of the current point.

x_granularity is the x spacing between points for the generate_data! message.

y_granularity is the y spacing between points for the generate_data! message.

value is the value at the current point.

range defines the (x,y) range in which the generate_data! message will interpolate values.

interval defines the number of points to generate in the x and y direction when a generate_data! message is sent.

elevations when non-zero, causes the generate_data! message to treat the value of the interpolated point as a z value. When zero, all z values generated are zero.

output_style when set to "triangles", causes the generate_data! message to generate triangle meshes. If set to anything else, quadrilaterals (not meshed) are generated.

generate_triangles when non-zero causes the generate_data! message to return the triangulated data. When zero, values are interpolated along a regular grid and that grid is returned.

interpolate_type when set to POWER_RAMP causes a distance-weighted sum over all points to be used as the current interpolated value. When set to PLANAR_INTERPOLATE, causes a planar interpolation within the enclosing delaunay triangle to be used.

MESSAGES

value= scalar sets the value for the current point.

value+ delta adds a delta to the value for the current point.

value? returns the value at the current point. This does not perform interpolation. It is only used to retrieve input values.

radius= scalar sets the radius of influence of the current point.

radius+ delta adds an increment to the radius of influence of the current point.

radius? returns the radius of influence of the current point.

x+ delta adds an increment to the current x value.

y+ delta adds an increment to the current y value.

x= scalar sets the current x value.

y= scalar sets the current y value.

@ (x,y) is shorthand for "x= x y= y".

interval= scalar sets the interpolation interval.

interval+ scalar increments the interpolation interval.

generate_data! generates a set of uniformly spaced points by interpolating from the unevenly spaced points input to the object. The output is to the display_data object named by the data_out instance variable. If the interval instance variable is set, the number of points generated is determined by the interval and the actual range of the data. If the x_granularity and y_granularity are set, the number of points generated is determined by the x and y granularity variables and the range variable. If the range is not set, it is assumed to be 0 to 500 in both x and y. If the generate_triangle instance variable is non-zero, then this message delegates to generate_triangle_data!.

generate_triangle_data! generates a set of triangles in the display_data object named by the data_out instance variable that corresponds to the Delaunay triangulation of the input points.

data_out= string sets the name of the display_data object that will be generated by the generate_data! message. If the object does not exist at the time this message is sent, a new display_data object is created.

file= string declares the file that contains input data.

elevations_on! enables elevation generation by the generate_data! message.

elevations_off! disables elevation generation by the generate_data! message.

power= scalar sets the power exponent for the current point. This value is used only if power ramp interpolation is enabled.

range= (xmin,ymin,xmax,ymax) sets the (x,y) range over which to interpolate values. This is used only by generate_data!.

x_granularity= scalar sets the number of points to interpolate along the x axis. This is used only by the generate_data!

message.

y_granularity= scalar sets the number of points to interpolate along the y axis. This is used only by the generate_data! message.

triangulate generates a Delaunay triangulation for the given points. Currently, an external progam, voronoi, is invoked to compute the triangulation. It must reside in one of the directories in the PATH environment variable or in $LYMB_ROOT/bin or $LYMB_ROOT/bin/$ARCH. (Internal)

power_ramp_on! enables interpolation using a distance-weighted sum of all points. A point's contribution to the interpolated value is non-zero if there is no enclosing polygon for the point, or there is an enclosing point and the point to be interpolated lies within the polygon.

planar_interpolate_on! enables interpolation using planar interpolation. The equation of the plane passing through the enclosing triangle's vertices is used to calculate a value at the current point.

generate_triangles_on! enables triangle generation by generate_data!.

generate_triangles_off! enables regular mesh generation by generate_data!.

triangle? returns the (x,y) coordinates of the triangle that enclose the current point.

interpolate? returns the interpolated value for the current point.

write_golf_file: name generates a specially formatted ASCII file for use as input to the View-A-Putt application.

write_byu_file: name generates a movie.byu file consisting of the input points and the Delaunay triangulation. This message should be generalized and moved into a separate class that generates movie.byu files from display_data objects.

read! reads a set of (x,y,value) tuples from the file named using the file instance variable. Each tuple must occur on a single line, separated by white space. If a fourth value is given, it is the radius for the point, used to determine the distance at which the point's influence on interpolated points goes to zero when using power ramp interpolation. If no radius is given, it defaults to 1.0.

polygon= (list) sets a clipping polygon for the current point. The list of points is a series of (x,y) pairs representing each point in the polygon.

output_style=triangles or polygons sets the type of output for the generate_triangle_data! message. If it is the string "triangles", then a triangle mesh is generated, a set of independent quadrilaterals.

EXAMPLE

This example shows how to create a two_d object that will interpolate values along a regular grid given a set of unevenly spaced points.

two_d new: level @ (86,90) value= 7.37 @ (103,148) value= 12.43 @ (63,57) value= 14.82 @ (115,106) value= 15.21 @ (112,124) value= 15.55 @ (83,62) value= 15.79 @ (88,164) value= 16.14 @ (92,150) value= 16.46 @ (88,172) value= 16.51 @ (90,163) value= 16.56 @ (91,159) value= 16.66 @ (118,113) value= 16.77 @ (106,148) value= 16.86 @ (95,154) value= 16.86 @ (81,177) value= 16.88 @ (100,158) value= 16.90 @ (71,56) value= 17.19 @ (76,62) value= 17.20 @ (50,152) value= 17.28 @ (117,101) value= 17.66 @ (109,140) value= 17.71 @ (84,153) value= 17.72 @ (51,148) value= 18.00 @ (114,74) value= 18.02 @ (85,83) value= 18.05 @ (47,165) value= 18.12 @ (87,78) value= 18.12 @ (57,142) value= 18.34

@ (55,154) value= 18.51 @ (44,138) value= 29.87

elevations_on! interval= 3 ;

display_surface new: level_surface data_in=level scalar_visibility_on! range=(7,30) ;

actor new: surface_actor modeller=level_surface ;

-- other stuff you need - camera, light, renderer camera new: c1 x_range=(0,130) -- xyz ranges based upon the data set size y_range=(0,200) z_range=(0,35) view_up=(0,1,0) position=(0,0,1) default! on! zoom: 2.5 clipping_range=(0.01,1000) ;

light new: l1 position=[c1 position?] focal_point=[c1 focal_point?] on! ;

environment new: env variable="LYMB_RENDERER" ;

object # [env value?] new: aren actors=[actor instances?] cameras=[camera instances?] lights=[light instances?] background=(0.5,0.5,0.5) ;

aren render!;

SEE ALSO

display_data


Please send comments and suggestions to
consult@rpi.edu