<< Chapter < Page
  Digital signal processing - dsp     Page 12 / 24
Chapter >> Page >

A 3D parabolic surface

The array of surface elevation data is populated by the code in Listing 2 .

Listing 2. A 3D parabolic surface,
for(int row = 0;row<numberRows;row++){ for(int col = 0;col<numberCols;col++){ int xSquare = col * col;int ySquare = row * row; data[row][col] = xSquare + ySquare;}//end col loop }//end row loop

I will allow you to evaluate this code on your own. It creates a 3D surface with the lowest elevation at the upper left corner and the highest elevation atthe lower right corner. The surface is a one-quarter section of a 3D parabola, as shown in Figure 3 .

Display six surface images

Listing 3 shows the code that causes the 3D surface elevation data to be displayed as six independent images (each statement in Listing 3 produces one output image) .

IMPORTANT: this is the same code that would be used by other programs to incorporate this 3D surface plottingcapability into those programs.
Listing 3. Display six surface images.
new ImgMod29(data,blockSize,true,0); new ImgMod29(data,blockSize,false,1);new ImgMod29(data,blockSize,true,2); new ImgMod29(data,blockSize,true,3);new ImgMod29(data,blockSize,false,4); new ImgMod29(data,blockSize,true,5);

Just instantiate an object

All that is necessary for another program to incorporate this class to display a 3D surface is to instantiate an object of the class named ImgMod29 passing four parameters to the constructor.

The parameters

The first parameter is a reference to the 2D array of type double containing the surface elevation values.

The second parameter is the blockSize . This int value specifies the size of one side of a square of pixels, (all of the same color) that will be used to represent each surface elevation value in the final display. As mentioned earlier, this value was set to 2 in the sampledisplays produced by the main method. However, it could have been any reasonable value such as 5, 10, or 15 for example.

The third parameter is true if you want the red axes to be drawn and is false otherwise (as shown in Figure 3 ) .

The fourth parameter is an integer value between 0 and 5 inclusive, which specifies the plotting format as follows:

  • 0 - Grayscale (linear)
  • 1 - Color Shift (linear)
  • 2 - Color Contour (linear)
  • 3 - Grayscale with logarithmic data conversion before plotting
  • 4 - Color Shift with logarithmic data conversion before plotting
  • 5 - Color Contour with logarithmic data conversion before plotting

Instantiate six separate objects

Listing 3 instantiates six such objects to display the same 3D surface, one for each plotting format as shown in Figure 3 . Some of the objects display the axes and others do not. All use a blockSize value of 2.

Each display object appears in the upper-left corner of the screen. Thus, when two or more such objects are instantiated, they appear as a stack. It isnecessary to physically move those on top of the stack to see those further down.

Listing 3 signals the end of the main method.

The ImgMod29 class

Listing 4 shows the beginning of the class named ImgMod29 and the beginning of the constructor for the class.

Questions & Answers

if three forces F1.f2 .f3 act at a point on a Cartesian plane in the daigram .....so if the question says write down the x and y components ..... I really don't understand
Syamthanda Reply
hey , can you please explain oxidation reaction & redox ?
Boitumelo Reply
hey , can you please explain oxidation reaction and redox ?
Boitumelo
for grade 12 or grade 11?
Sibulele
the value of V1 and V2
Tumelo Reply
advantages of electrons in a circuit
Rethabile Reply
we're do you find electromagnetism past papers
Ntombifuthi
what a normal force
Tholulwazi Reply
it is the force or component of the force that the surface exert on an object incontact with it and which acts perpendicular to the surface
Sihle
what is physics?
Petrus Reply
what is the half reaction of Potassium and chlorine
Anna Reply
how to calculate coefficient of static friction
Lisa Reply
how to calculate static friction
Lisa
How to calculate a current
Tumelo
how to calculate the magnitude of horizontal component of the applied force
Mogano
How to calculate force
Monambi
a structure of a thermocouple used to measure inner temperature
Anna Reply
a fixed gas of a mass is held at standard pressure temperature of 15 degrees Celsius .Calculate the temperature of the gas in Celsius if the pressure is changed to 2×10 to the power 4
Amahle Reply
How is energy being used in bonding?
Raymond Reply
what is acceleration
Syamthanda Reply
a rate of change in velocity of an object whith respect to time
Khuthadzo
how can we find the moment of torque of a circular object
Kidist
Acceleration is a rate of change in velocity.
Justice
t =r×f
Khuthadzo
how to calculate tension by substitution
Precious Reply
hi
Shongi
hi
Leago
use fnet method. how many obects are being calculated ?
Khuthadzo
khuthadzo hii
Hulisani
how to calculate acceleration and tension force
Lungile Reply
you use Fnet equals ma , newtoms second law formula
Masego
please help me with vectors in two dimensions
Mulaudzi Reply
how to calculate normal force
Mulaudzi
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask