Für neue Autoren:
kostenlos, einfach und schnell
Für bereits registrierte Autoren
Veröffentlichen auch Sie Ihre Arbeiten - es ist ganz einfach!
Mehr InfosBachelorarbeit, 2002, 127 Seiten
Bachelorarbeit
Донецький національний технічний університет (Mathematics and Computer Studies)
1,0
Table of Contents
1 Introduction
1.1 Visualisation
1.2 History
1.3 Literature Review
1.4 Summary of Dissertation
2 The Application
2.1 Overall
2.2 Components
2.2.1 Toolbar
2.2.2 Information Window
2.2.3 Manipulation Modes
2.2.4 Contour Map
2.2.5 Acquiring data files
2.2.6 Creating datasets of mathematical formulas
2.2.7 Colour Shading
2.3 User Profile
2.4 Alternatives for CoVis
3 Technical Foundations
3.1 Win32 API
3.1.1 Why I chose the Win32 API
3.1.2 Creating a window
3.1.3 Event Handling
3.1.4 Keyboard Handling
3.1.5 Mouse Handling
3.1.6 Resources
3.1.7 Buttons
3.1.8 Edit Controls
3.1.9 List Boxes
3.1.10 Trackbars
3.1.11 Menus
3.2 OpenGL
3.2.1 The OpenGL architecture
3.2.2 Creating an OpenGL window
3.2.3 Adapting the OpenGL Scene
3.2.4 Objects
3.2.5 Colours
3.2.6 Fonts in Open GL
4 Data Representation
4.1 Equally spaced data points
4.1.1 Meshes
4.1.2 Isometric surfaces
4.1.3 Contour plots
4.1.4 File format
4.2 Unequally spaced data points
4.2.1 Delaunay Triangulation
4.2.2 Contour Plots
4.2.3 File format
5 Conclusion & Future Work
Bibliography
Figure 1.1 Representation of mathematical functions on XY-plane
Figure 1.2: Curve of mathematical function f(x)=x²
Figure 1.3: Visualisation of a mathematical function of two variables f(x,y)=x²+y²
Figure 1.4: Typical contour plot
Figure 1.5: Population of Sweden between 1750 and
Figure 2.1: CoVis3 visualising a mathematical formula
Figure 2.2: Window structure of CoVis
Figure 2.3: Dependencies in CoVis3
Figure 2.4: Main Window of CoVis3
Figure 2.5: Different mouse cursors of CoVis3
Figure 2.6: Rotation mode
Figure 2.7: Contour map of ice-thickness dataset at the value of 1846.6m
Figure 2.8: Dialog for changing the contour value
Figure 2.9: Loading a dataset
Figure 2.10: After the user has selected an unequally spaced dataset, the application connects the data points
Figure 2.11: Dialog for creating a dataset of a mathematical function
Figure 2.12: CoVis3 performing the mathematical formula f(x,y)=x²·y²
Figure 2.13: Adjusting colour shading
Figure 2.14: Main screen of Maple 5, visualising a mathematical equation of two unknowns
Figure 2.15: Matlab performing a composite mathematical formula
Figure 2.16: 3D surface chart of Microsoft Excel
Figure 3.1: Dependencies for Win
Figure 3.2: A typical Trackbar
Figure 3.3: The OpenGL rendering pipeline
Figure 3.4: OpenGL hierarchy on Windows systems
Figure 3.5: Triangle with smooth colour shading
Figure 4.1: Equally spaced data points
Figure 4.2: Unequally spaced data points
Figure 4.3: Mesh plot of Abbildung in dieser Leseprobe nicht enthalten as isometric view
Figure 4.4: Four equally spaced data points
Figure 4.5: Values referring to contour value
Figure 4.6: Simplest possibility of contour within the marching square
Figure 4.7: 16 marching squares
Figure 4.8: Contour plot of Abbildung in dieser Leseprobe nicht enthalten
Figure 4.9: File format for equally spaced datasets: .esd
Figure 4.10: Possible connections of four data points
Figure 4.11: Two triangles, not fulfilling the circumcircle criterion
Figure 4.12: Two triangles, fulfilling the circumcircle criterion
Figure 4.13: Ambiguous case in Delaunay Triangulation
Figure 4.14: Intersection of perpendicular bisectors
Figure 4.15: New sample point to be added to existing triangular mesh
Figure 4.16: Triangles whose circumcircle encloses the new sample point
Figure 4.17: Triangular mesh after removing doubly specified edges
Figure 4.18: New triangles formed from new point to the outside edges of the enclosing polygon
Figure 4.19: The supertriangle is encloses every sample point
Figure 4.20: 8 possible marching triangles
Figure 4.21: File format for unequally spaced datasets: .usd
Numerical data, in its raw form, is extremely difficult to assimilate. The larger and more complicated the datasets, the more unlikely it is that a reader will be able to ascertain the most implicit characteristics of the information from the basic data. An effective graphical representation should clearly display the critical features of the data.
Visualisation of data starts with a facility to visualise mathematical functions. Mathematical functions of two variables f(x,y) can describe three dimensional surfaces, where each value of x and y defines a certain function value. These values can then be transferred to the z-axis z=f(x,y). Figure 1.1 shows a surface generated by the mathematical function f(x,y)=0. As this formula describes that every point on the XY-plane equals 0, the resulting surface has no elevations.
Abbildung in dieser Leseprobe nicht enthalten
Figure 1.1 Representation of mathematical functions on XY-plane
In order to understand mathematical formulas with two variables, we have to consider these formulas from a very basic point of view. Mathematical functions with one variable f(x) describe curves. This occurs because each value of x defines a certain value in y direction Abbildung in dieser Leseprobe nicht enthalten. Figure 1.2 shows the curve of the formula for f(x)=x².
Abbildung in dieser Leseprobe nicht enthalten
Figure 1.2: Curve of mathematical function f(x)=x²
As already discussed, the definition of surfaces needs formulas of two variables. In three dimensions, it is possible to define a formula depending on x ( which is meant by f(x)) to either the y axis or the z axis of the coordinate system. If we apply the formula f(x)=x² to the z axis, and also the formula f(y)=y² to the z axis, these two formulas describe an outline for a surface.
Abbildung in dieser Leseprobe nicht enthalten
Figure 1.3: Visualisation of a mathematical function of two variables f(x,y)=x²+y²
However, the difficult part is to find how to combine these formulas. A simple way of achieving this is to add both values for x and y. This results in the formula f(x,y)=x²+y². Figure 1.3 illustrates this mathematical function of two variables.
In engineering it is a broadly common to describe surfaces with mathematical functions. For example car manufacturing needs methods to describe aerodynamic surfaces for bonnets or wings. In these situations mathematical functions are better suited than data points connected by lines because surfaces described by mathematical functions provide an infinite accuracy. One problem with functions however is that they can only be represented by a series of data points calculated from the function. A mathematical function can only be approximated by a dataset, containing a finite number of sample points.
Nevertheless, data can also be obtained by direct measuring of physical objects. Nowadays there are many areas where huge quantities of measured data have to be visualised (e.g. in scientific and medical areas). In medical areas it is vital to facilitate the view of parts of the human body or even the entire human body. There are also methods to obtain data from the surface of an object. One such technique is laser scanning. This technique simply measures the distance from the object’s surface to the laser. The laser then continues scanning and recording data from every spot of the object. This method is not only applicable in medical areas; it can be used for almost every object. Often there is a need for displaying objects that are obscured from direct view. One example for this is the visualisation of objects hidden by the human body like the heart or the lever. This is already possible through the discovery of X-Rays. Another methods involve the collection of data by ultrasonic.
However, there are also very powerful techniques for visualising three-dimensional data as two-dimensional representations. For maps it is necessary to have a technique to visualise data of the third dimension – the height. Therefore contour lines provide a very good representation of heights. A contour line joins points of equal elevation so that everything within the boundaries of one contour line is at approximately the same elevation.
Abbildung in dieser Leseprobe nicht enthalten
Figure 1.4: Typical contour plot
Visualisation of data is a very old problem that mankind always had to contend with. A very early form of attempting to visually represent numerical data were maps, which used quite simplistic methods to transfer measured data to paper. Maps are still in use today, which shows their appropriateness for visually representing measured data. However, this two-dimensional representation of data is quite limited. For more complex data this technique reaches its limitations.
At the end of the 19th century, when more statistical data came available, several methods for visualisation of 3D data were developed. The first approach to visually represent three-dimensional data was made around 1880 [13]. Figure 1.5 shows one of the first three-dimensional visualisations of statistical data. This chart describes the population of Sweden between 1750 and 1875 within different age groups.
Abbildung in dieser Leseprobe nicht enthalten
Figure 1.5: Population of Sweden between 1750 and 1875
Until the development of sophisticated computer graphics in the 1980s it was very difficult and time-consuming to create 3D data charts. Today, with the support of computers, we are able to visualise data in several different ways. One method that has only become possible with computers is the rendering of data into a virtual 3D world. In 1992 Silicon Graphics, Inc. developed the platform independent graphics API OpenGL, which formed a standard of modern computer visualisation for personal computers.
Initially I only intended to visualise mathematical formulas. In the course of the project I realised that everything, may it be a mathematical function or data of ice thickness has to be stored in datasets to allow fast visualisation methods. If we have a mathematical function and the values of the data points always have to be calculated when the angle of view changes, the resulting performance of the software is rather poor.
As I already mentioned the main aim of this project is to visualise functions & datasets. Since this demands a highly sophisticated 3-dimensional environment, I decided to use OpenGL for my project. By searching the Internet for OpenGL related sites, I came across a brilliant website called NEHE OpenGL Tutorials [5]. This site describes OpenGL in different Tutorials. It starts with a tutorial for setting up an OpenGL window and continues with creating 3-dimensional objects, colour shading and coordinate transformations (rotating and scaling). I studied the source code of these sites and adapted it for CoVis3. To collect more information about OpenGL, I came across the book OpenGL Superbible [6]. This book explains single OpenGL commands and geometrical transformations in much more detail.
During the development of the project, it realised that I need some possibilities to interact with the program in addition to the keyboard handling that is described on the NEHE website. I intended to insert a menu and a toolbar to the OpenGL window, to allow the user for more interaction with the program. This demanded a fundamental understanding of Win32. Therefore I found the book Win32 Programming API Bible [3], which describes how to create menus, dialog boxes and much more in high detail. In section “Menus” of the Technical Foundations chapter I describe how to set up a menu in detail. Furthermore the standard MS-SDK Win32 [4] help file provided me with additional information for the application.
The next step of this project was to load existing datasets. Therefore I came across a website from the National snow & Ice data centre [7]. This website contains huge amounts of datasets that are stored in text files. There were some other web sites that contain data sets as well: [8], [9] (see Bibliography). As further investigations I wrote algorithms for obtaining this real life data. The next problem I had was to find a way to connect the data points (see chapter 4 – Data Representations). My first attempts to find algorithms for connecting these data points were convex hull – algorithms. But these attempts concluded in methodological failures. Then I found a brilliant algorithm for triangulation – The Delaunay Triangulation Algorithm: [11], [12], [15].
The broad aim of this project is to investigate different visualisation methods for the visualisation of mathematical functions of two variables and 3D data. It is mainly focused on visualising 3D datasets in a three-dimensional environment. I chose the graphics library OpenGL for the realisation of this environment. OpenGL is capable of very sophisticated 3D-operations, which are necessary for proper visualisation of this type. Furthermore I developed an algorithm for drawing ISO-surfaces on a standard canvas without using OpenGL.
The main part of this project was to create an application, which allows exploring the researched visualisation methods – CoVis3. In particular this application allows visualising 3D datasets and mathematical formulas of two variables. The different features of CoVis3 are described in chapter 2. In order to visualise both mathematical functions and 3D data, I had to distinguish between equally spaced and unequally spaced datasets. Datasets created by a mathematical function are stored equally spaced and real life data usually occurs in an unequally spaced form. The difference between equally and unequally spaced data is explained in chapter 4.
To understand the relations between the commands of OpenGL, I implemented the whole application in Win32. Chapter 3 – Technical Foundations gives a broad understanding of Win32 commands and programming techniques I have used. Furthermore I wanted to learn the commands of Win32 in order to understand what is going on behind MFC. Hence I did not use any object-oriented code. As further objectives of the project it may be possible to wrap the procedural structure of the program into classes. However, this is not necessary as the procedural structure of it is very well organised. See chapter 5 – Conclusion & Future Work.
CoVis3 is an application that demonstrates visualisation methods for both mathematical formulas and real life data. Figure 2.1 shows the main window of CoVis3 and its window structure performing a mathematical formula of two variables. The mathematical formula for describing this particular surface is f(x,y)=0.25*sin(4x+sin(4y)).
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.1: CoVis3 visualising a mathematical formula
CoVis3 is an interactive application for visualising datasets & functions through a surface. It can also display data-related information. This means that it is possible to load a dataset into the application. It is also possible to create new datasets by selecting mathematical formulas. CoVis3 is capable of visualising data in two different methods. One of them is the visualisation of surfaces with OpenGL. The other method is the visualisation as a contour plot. Once a dataset is created or loaded into the application, it can be displayed and analysed in a three-dimensional environment. It is possible to survey the dataset in many different ways. The view can be rotated and moved by dragging the surface and the information of heights can be represented as colours. This results in a highly expressive and useful image of the dataset.
The peculiarity of CoVis3 is its window architecture, which embeds an OpenGL window for three-dimensional explorations. Figure 2.2 illustrates the window structure of CoVis3. This window structure enables the user to see all the important information on the first sight.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.2: Window structure of CoVis3
CoVis3 has the facility to represent equally or unequally spaced data. As shown in Figure 2.3, equally spaced datasets can either be acquired by loading a dataset, which data points have equally distances to each other or by creating equally spaced data points with a mathematical formula. Real life data however may contain data points whose distances aren’t equally spaced. This depends on the method of measuring. If the data points are randomly picked, it is understandable that the dataset will contain unequally spaced data points. Equally spaced data points have to be measured on a regular grid.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.3: Dependencies in CoVis3
As already mentioned, the user is provided with a variety of visual information. As shown in Figure 2.3, it is possible to visualise the data in 3 different ways. In addition to the free movable 3D scene, which can be manipulated by the user, additional information about the dataset is displayed. Moreover CoVis3 provides a contour map that represents different height values as single lines as further information. This additional information is available to the user as soon as the dataset is loaded. For getting this information the user doesn’t have to perform further tasks.
The following section describes the design of the different components of CoVis3. These components were developed bearing in mind the principles of task analysis and usability. Usability was an essential aspect for the design evaluation of components for CoVis3. Every task in CoVis3 is aimed to fulfil the user’s goals. Figure 2.4 illustrates the main window of CoVis3, based on an ice-thickness dataset of a region in Antarctica.
The main window is split into three different sub-windows. The biggest part is the actual scene with the visualised dataset. The upper right window displays a contour plot, which I will explain later on in more detail. The bottom window on the right hand side provides the user with information about the dataset. Moreover there is a toolbar, which makes all operations accessible to the user.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.4: Main Window of CoVis3
The Toolbar provides the user with standard file operations (like new, open and save) and different manipulation modes, which I will deal with in Section 2.2.3 in more detail. In Figure 2 we can see three different buttons for manipulation modes; the button for the rotation mode is currently selected. The next button allows users to enable or disable a grid, which outlines the different polygons of the surface exactly. The colourful button right beside it allows for the adjustment of the current colour shading of the surface. The purpose of the last button (labelled “Contour”) is to adjust the contour value for the contour map (see Contour Plot).
This window provides the user with additional information about the dataset. As we see in Figure 2, it is positioned on the right side, at the lower half of the main window. It detects, whether or not a dataset is loaded. If so, it retrieves available information about the dataset. The user can see what type the current dataset belongs to, what the origin of the data is and what the minimum and maximum values of the dataset are. Furthermore a short description of the dataset is available. As the origin of the dataset is a data file, it just indicates “File” in the field “Origin”. The actual filename is shown in the window title of CoVis3. The user is also informed about the number of data points in the dataset. It is important to realise that vast amounts of data points increase the demand on computational resources. Colours are used to represent the heights of a dataset, where each colour represents a certain height. The colour stripe within the information window shows the minimum and maximum value of the dataset and the colour shading between these extreme values. I will deal with colour shading in section 4.3.
A special feature of CoVis3 are three different manipulation modes. The user has the choice between moving, rotating and zooming the current three-dimensional scene.
In order to manipulate the view of the surface, it is necessary to link the possible movements of the three dimensional environment to the input devices of the computer. Nowadays the most frequently used input device is the mouse. Unfortunately the mouse is only a two dimensional input device, which is inadequate for manipulation of 3D-space. There are other input devices like cyber gloves that are much more appropriate for this problem. But only a minority of users own such input devices. Therefore, in attempting to use the mouse to manipulate the scene, it is crucial to separate the 3D movement into different sub movements with 2 or 1 degrees of freedom. First of all it is possible to think of the rotation about a single axis as a subtask. Although this seems easy applicable, the lack of the third dimension causes that the view can only be rotated in two dimensions. In terms of user expectations the most appropriate way of rotation with mouse input is presumably the following: The user might expect to drag and drop the current view. The most adequate way is that the user drags the very front point of the scene.
The cursor style is used to clearly indicate the selected manipulation mode. Figure 2.5 shows the application in the rotation mode. The cursor only appears as a rotation cursor when it is within the scene window. If it is over the window of the contour plot or over the menu, it instantly changes to the standard arrow cursor. The user can rotate the object by simply dragging it with the mouse. Each of the manipulation modes has its own mouse cursor. Figure 2.5 shows the different mouse cursors.
Abbildung in dieser Leseprobe nicht enthalten move
Abbildung in dieser Leseprobe nicht enthalten rotate
Abbildung in dieser Leseprobe nicht enthalten zoom
Figure 2.5: Different mouse cursors of CoVis3
In the move mode the user can move the object left, right, up and down by simply clicking on it, dragging it to the desired position and dropping it there. The rotation mode, however, is more sophisticated. If you imagine an axis from the left side to the right side of the monitor, you can rotate the object around this axis by dragging it up and down. Hence mouse movements in horizontal directions are rotated around an imaginary axis from top to bottom of the monitor. Figure 2.6 shows the implication of mouse movements in the rotation mode.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.6: Rotation mode
The last manipulation mode is the zoom mode which any user would expect in the application. The surface moves towards the user, and this increases in size
A contour map is another excellent method of visually representing data. A contour is a line joining points of equal height. We can also describe a contour as a plane cut through a surface a certain height value. A contour map can either contain one contour line for one height value or several contour plots. For CoVis3 I decided to visualise only one particular contour line, as this already shows loads of information. Figure 7 again shows the contour map of the main window of CoVis3. The red line on this map represents the contour value of 1846.6m. The user can already get much information from this illustration.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.7: Contour map of ice-thickness dataset at the value of 1846.6m
The name of this application wouldn’t be CoVis3, if there was no opportunity for the user to change the contour value. Figure 8 shows the dialog box, which appears when the user clicks on the contour map or presses the “Contour” button in the task bar. This dialog box is not modal, which means that users can change between this dialog box and the main window. When the user moves the slider of the track bar, the contour value correspondingly changes. The peculiarity of this dialog box is that the contour line of the contour map in the main window smoothly changes when the user moves the slider. This is the actual purpose of this dialog box – to provide the user with a great flexibility.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.8: Dialog for changing the contour value
As already mentioned the main feature of CoVis3 is to visualise datasets. The most common way to obtain data is to load data files. CoVis3 allows loading datasets of two different formats. Equally spaced datasets and unequally spaced datasets. Figure 2.9 illustrates the dialog for loading both equally and unequally spaced datasets.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.9: Loading a dataset
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.10: After the user has selected an unequally spaced dataset, the application connects the data points
At this stage I have to mention an interface design problem that is caused by implementation. After the application has loaded an unequally spaced dataset selected by the user, the program has to generate triangles between the single points of the dataset to provide the user with a good looking, regularly connected surface. Unfortunately, depending on the size of a dataset, this algorithm can take some time to perform. It takes about 100 times longer to generate the triangles than just loading the dataset from hard disk. For that purpose it is necessary to inform the user about the progress of this algorithm, to guarantee the patience of the user. Considering users of this application are supposed to be advanced or even professional users, they will certainly expect to be kept informed of what is going on “behind the scenes”. So if the title of this dialog (shown in Figure 2.10) was just “Opening dataset…”, the user would be suspicious as to whether the application was actually loading the dataset or not. The fact the hard disk is accessed only during the initial period of the execution may also increase the suspicion of the user. Hence I include an indicator of processing stage realised through an appropriate dialog. Thus the user can perform other work within the application while the algorithm is computing.
In order to provide the user with a big variety of formulas, it is necessary to have a quite sophisticated interface. Figure 2.11 shows the interface for creating a new dataset with a mathematical formula.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.11: Dialog for creating a dataset of a mathematical function
This interface allows the user to edit a variety of formulas. In order to display a mathematical function, it is necessary to define a certain range. It is not possible to display an entire function. Thus it is possible to change the range of the function. As illustrated in Figure 2.11 the area in the upper left corner of the window defines this range. A range of –1 to +1 for both x and y direction is predefined. This range can be changed to any values. It is also possible to change the exactness of the calculated dataset. This describes how many data points the calculated dataset will contain. As in this example an exactness of 20 data points in both x and y direction would conclude in 400 data points.
In order to provide a good overview of mathematical equation, I have separated these into four categories (Linear, quadratic, trigonometric and special functions). Linear functions are very simply and conclude in surfaces with equal slopes at any position. f(x,y)=3x+y is an example for a linear equation. Quadratic functions summarise all functions with the exponent 2. An example for a quadratic function is f(x,y)=x²+y², which was already illustrated in Figure 1.3. Trigonometric functions include formulas with sin and cos. One example is f(x,y)=sin(x)+cos(y). The section Special only holds one famous formula. The Ovals of Cassini.
The formula for it is Abbildung in dieser Leseprobe nicht enthalten.
More flexibility for formulas guarantees the use of changeable variables. Every formula that can be selected encloses any of the variables a, b, c and d. It is possible to change these variables, listed in the upper right corner of the window (Figure 2.11).
After the dataset of the mathematical formula is created, CoVis3 shows it. Figure 2.12 shows the application performing an equally spaced dataset created by CoVis3. The formula used to create this particular dataset was f(x,y)=x²·y². As we can see on the contour map the dataset is stored as a regular grid. Each intersection of the grid represents a data point. With equally spaced datasets the 3D view is more expressive with a grid (illustrated in Figure 2.12).
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.12: CoVis3 performing the mathematical formula f(x,y)=x²·y²
As further information you can already see that the function f(x,y)=x²·y² has a minimum of 0 and a maximum of 1 in the range of -1 to 1 in both x and y direction. Furthermore the majority of this area and the middle points of the outer edges have a value near 0. The four corners of the area have the value 1. There is already quite lot information we can get from this frozen 3-dimensional portrayal of the function.
As obvious from previous illustrations, CoVis3 visualises the datasets by defining certain colour values for height. This technique is known as “height depending colour shading”. In order to guarantee more flexibility, it is possible to adjust the colour shading of the surface. Figure 14 shows the dialog that allows the user to manipulate to the colour shading of the surface. There are two possibilities of adjusting the colour shading.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.13: Adjusting colour shading
The user can either choose a solid colour of his/her choice or a linear gradient of two colours. An additional option is the rainbow shading which is applied in Figure 2.1 and Figure 2.12. The user will instantly see the result in the same dialog when he changes a colour. This avoids that the user has to press the OK button every time he changes a colour just to find out that the colour doesn’t fulfil his expectations and also avoids that he has to start the dialog again. This keeps “Adjust colour shading” as one single task, which doesn’t waste useful time of the user.
CoVis3 is not for a very broad area of users. It is meant for advanced and professional users who want to visualize a dataset of their domain. A great variety of surfaces can be visualized with CoVis3. May it be mathematical formulas or real life data that has been measured from existing surfaces. Geologists for example can visualize their datasets, which contain information about positions and heights of a certain area on earth. Meteorologists can visualize weather information like low-pressure areas or clouds. CoVis3 is also useful for medical areas. Data obtained by laser scans or ultra sonic can be visualized as surfaces, which might be a benefit for professionals of medical areas.
The option of visualising mathematical functions might as well be interesting for students as for professionals of mathematical areas. It is an adequate way of visualising mathematical equations as a three dimensional surface. Students can use CoVis3 for educational purposes. It can provide broad comprehension of mathematical formulas.
Users of Computer Visualisation should at least have a fundamental understanding about three-dimensional datasets. Furthermore basic knowledge about mathematical formulas with two unknowns might be necessary to create datasets with mathematical formulas. The user should as well be familiar with editing text files in order to manipulate datasets and to create datasets manually.
There are many tools out there for visualising mathematical functions with two unknowns. The most popular applications are mathematical programs like Matlab or Maple. These applications are undeniably more complex than CoVis3. They include features like equation solving, derivations and integrals. However, the quality of three-dimensional surface plots within CoVis3 equals or even surpasses the quality of plots within applications like Matlab or Maple. This is mainly caused by the use of OpenGL for the visualisation of these formulas. A disadvantage of complex mathematical applications like Matlab or Maple is the fact that the price usually exceeds the affordable. Maple 5 supports an own script language, which allows the user to edit a huge variety of formulas. Figure 2.14 shows the main screen of Maple 5, performing complex mathematical operations.. The displayed function obviously is
Abbildung in dieser Leseprobe nicht enthalten.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.14: Main screen of Maple 5, visualising a mathematical equation of two unknowns
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.15: Matlab performing a composite mathematical formula
Figure 2.15 shows Matlab performing the visualisation of a 3 dimensional surface calculated by a mathematical function. The quality of this representation is rather high. However, the possibility to rotate and zoom the object in every thinkable direction, as provided by CoVis3, is not possible with this application.
Microsoft Excel® also allows the visualisation of mathematical functions. However, complex formulas must be entered separately for every data point. Table 1 shows the data of the function f(x,y)=x²+y². Assuming the first row of this table (1) represents the x-value and the first column (A) represents the y-value of the function, we can easily define the formula for each point of the XY-plane. As an example the formula in cell E5 for f(x,y)=x²+y² would be =E1*E1+A5*A5 to calculate the sum of the squared coordinates.
Abbildung in dieser Leseprobe nicht enthalten
Table 2.1: Data of function f(x,y)=x²+y².
As soon as the dataset for the formula is set up, it is possible to create a chart of this data. Figure 2.16 shows the visual representation of this data. Within Microsoft Excel® this representation is called 3D surface chart.
Abbildung in dieser Leseprobe nicht enthalten
Figure 2.16: 3D surface chart of Microsoft Excel
Although the graphical quality of this surface is not as high as the quality provided by CoVis3, the option of displaying multiple contour lines (as shown in Figure 2.16) is very powerful. The advantage of Microsoft Excel® is its great spreading.
The Win32 API provides an interface that allows accessing visual characteristics of Microsoft Windows® like windows, buttons and text fields, which are provided by this operating system. For every task within Microsoft Windows® Win32 commands have to be executed. The abbreviation API stands for Application Programming Interface.
As illustrated in Figure 3.1, class orientated attempts like MFC are on top of the Win32 architecture and use commands of Win32 within the implementation of class structures as well. Unfortunately MFC does not provide every single function provided by the Win32 API. This was one of the reasons why I chose the Win32 API. Furthermore programs that are entirely implemented with Win32 are faster than MFC programs. One of the reasons for this is that libraries for MFC do not have to be included to the program. Another reason I chose Win32 instead of MFC was that the example source code I used for OpenGL was entirely implemented in Win32 and most examples in the OpenGL Superbible are coded in Win32 as well. Moreover I have some experience in Win32 so far and I am very interested to increase my knowledge in this area. It is very useful for a developer to know what is going on “behind the scenes”. Since MFC is based on Win32 it is easy to comprehend single steps that the implementation of MFC is performing.
Abbildung in dieser Leseprobe nicht enthalten
Figure 3.1: Dependencies for Win32
The most important task for a Win32 application is to create a window. A window is a rectangular area of the screen where the application displays output and receives input from the user. It shares the screen with other windows, including those from other applications. Only one window at a time can receive input from the user.
First of all I will point out the differences between a Win32 program and a common console application: A console application in C/C++ needs a main function to be executable after compiling and linking.
Abbildung in dieser Leseprobe nicht enthalten
In contrary the main part of a Win32 application has to be the WinMain function of the form
Abbildung in dieser Leseprobe nicht enthalten
This is equivalent to the main() function in DOS/UNIX. The first parameter hInstance is the handle for the program’s executable module, whereas the next parameter has to be NULL for every Win32 application. The third one holds the command line arguments as a char* and the last one must be transmitted to the final ShowWindow() function.
The following source code should give an impression of what is necessary to create a window in Win32:
Abbildung in dieser Leseprobe nicht enthalten
An application creates its windows (including the main window) by using the CreateWindow or CreateWindowEx function and providing the information Windows requires defining the attributes of the window. Therefore a window class has to be defined before creating the window. As in the source code above, the members of the WNDCLASSEX structure have to be defined before calling RegisterClassEx(), which registers the window class. The argument of the RegisterClassEx() function must be a pointer to a WNDCLASSEX structure. The members of this structure affect the window class as follows:
The membercbSizedefines the size of the structure. Usually it is enough to define it with the sizeof(WNDCLASSEX) function. The next member isstyle, which represents the class style. Usually this can be set to NULL.lpfnWndProcis a pointer to the window procedure for the current window class. The window procedure is very important to handle messages. I will describe this in more detail later on. The membercbClsExtradefines the amount of extra data allocated for the window class in memory. The same exists for the amount of extra data allocated in memory per window. It is calledcbWndExtra. They can both be set to NULL. The following memberhInstanceis very important. It is the handle to the application instance, which can easily be obtained by the first parameter of the WinMain function. The hIcon member defines the large icon of the application. In the shown source code example it is set to LoadIcon(NULL, IDI_APPLICATION) which means that the standard application symbol is used. The memberhCursoruses the same technique. It defines the cursor that will be displayed over the window and it defines the standard cursor as well. The next item is quite obvious.hbrBackgroundsets the background colour of the window. The application may also contain a menu. In this case the memberlpszMenuNamehas to contain the name of a menu resource. Of course the defined class structure has to have a name. ThereforelpszClassNameidentifies the class name. Finally the itemhIconSmdefines a small icon to be shown in the taskbar and in the top left corner of the window.
After the definition of our window class the class can be registered with the command RegisterClassEx. It has to obtain a pointer to the window class as the argument.
In order to create the window, the Win32 API provides the command CreateWindow. The first parameter of it is our defined window class. The second parameter defines the window title that is shown at the top of the window. The following argument defines the window style. The next four parameters (100, 100, 320, 240) are the X and Y co-ordinates for the upper left corner of the window and the width and height.
The next parameter I mention at this point is the second last one. This is the most important one. It holds an instance of our window.
Finally we can show the window with the following commands.
Abbildung in dieser Leseprobe nicht enthalten
In order to handle window messages (events) like mouse or keyboard inputs, we need to define a WndProc function.
Abbildung in dieser Leseprobe nicht enthalten
This is the window procedure. It handles all of the messages that our window receives. LRESULT is simply a long. Windows programs, unlike DOS programs, are event or message driven. This means that in general they do nothing until they receive a message, they act on the message and wait for the next message. CALLBACK means that the WndProc function will be executed by Windows, whenever a message occurs. To tell Windows the current window procedure, it is necessary to define the lpfnWndProc member of our window class with the name of the window procedure.
Abbildung in dieser Leseprobe nicht enthalten
When a message is sent to the window, it calls the windows procedure. and by checking the value of the Message parameter we can see which message it was. After a message arrives the message parameter uMsg contains the information of this message. The parameters wParam and lParam are used differently by each message to provide additional information relating to the message.
Since the window procedure above is not handling any messages, all necessary is to handle WM_CLOSE and WM_DESTROY to allow the program to be closed. Otherwise clicking on the [x] button on the window would have no effect and the user would need to hit Ctrl+Alt+Del to terminate the program.
Abbildung in dieser Leseprobe nicht enthalten
The following technique handles keyboard messages. It is possible to store pressed keys in an array, so that more than one key at a time can be stored. The array can store all 256 ASCII codes for any pressed key.
Abbildung in dieser Leseprobe nicht enthalten
Within the WndProc function, it is necessary to wait for the messages WM_KEYDOWN, when a key is held down and WM_KEYUP when a key is released. If the message is WM_KEYDOWN , I simply define the current key in our array as true and at WM_KEYDOWN I define it as false again.
Abbildung in dieser Leseprobe nicht enthalten
Abbildung in dieser Leseprobe nicht enthalten
If there is no message waiting, the keyboard array can be checked for every key. Therefore we need to check whether or not a message is waiting. The command PeekMessage checks the input stream for a waiting message.
MSG msg;
Abbildung in dieser Leseprobe nicht enthalten
This keyboard handling does not have to be within the window procedure.
There are three different mouse messages that I will point out in this section. WM_MOUSEMOVE, which indicates that the mouse is moved, WM_LBUTTONDOWN, which means that the left mouse button is held down and finally the WM_BUTTONUP message that indicates the released left mouse button. There are a lot more mouse messages, but at this point these three are sufficient. In the event WM_MOUSEMOVE, the parameter lParam indicates the position of the mouse cursor. The function LOWORD(lParam) retrieves the x position and HIWORD(lParam) the y position of the mouse cursor.
[...]
Diplomarbeit, 101 Seiten
Diplomarbeit, 83 Seiten
Kommentare