Use a program to plot the velocity distribution curve

Source: Internet
Author: User
(HTML is an incomplete version. Image, code please download/files/zuroc/physics.rar and/files/zuroc/onWay-1.doc)

Programmer, on the road ......

Section 1st

Title: Use a program to plot the velocity distribution curve

Overview: Windows SDK + openel display images

Body:

Today, someone came to me and asked me if I could help him draw an image of a physical problem. In my opinion, I found that my homework has been pulled down a lot. I think we should study well from now on. The program is only a small part of the world, and the real masters should be integrated.

However, no matter how the program is written, it uses Windows SDK + openel. In fact, I am new to these two things. I hope someone can give me more advice.

See the attachment for the program. The formula is in "expressions. H", and the plotting program is in "draw. h". For more information, see references.

At the beginning, I used debug for compilation, and there were many errors when using release for compilation.Each configuration file must be manually connected to the database..

Legacy problems:

1. In Windows, how does one enable the command line output status and input parameters? Now, the parameters are written to the program?

2. Why is the resource usage of this program system so large?

3. I can see these two sentences in the header file of zlib.

Typedef voidpf (* alloc_func) of (voidpf opaque, uint items, uint size ));

Typedef void (* free_func) of (voidpf opaque, voidpf address ));

What does this mean? Generally, this format is not typedef vector <int> vec_int?

Knowledge point:

1. the header file of the library required by openggl is as follows:

# Include <windows. h> // header file for Windows

# Include <GL \ Gl. h> // header file for the opengl32 Library

# Include <GL \ Glu. h> // header file for the glu32 Library

# Include <GL \ Glaux. h> // header file for the Glaux Library

W

2. Connection Method of the library required by openggl (the following is vs2003)

3. OpenGL functions

// Clear the screen to the specified color and clear the depth Cache

Glclear (gl_color_buffer_bit | gl_depth_buffer_bit); // clear the screen and the depth buffer

// Reset scenario)

Glloadidentity (); // reset the current model view Matrix

// The function of gltranslatef (x, y, z) is to move along the X, Y, and Z axes. The following code moves 1.5 units to the left on the X axis, the Y axis does not move (0.0), and the Z axis moves 6.0 units to the screen. Note that when you move, you do it relative to the current position, rather than the center position of the screen (scene.

Gltranslatef ( -1.5f , 0.0f, -6.0f ); // Move left 1.5 units and into the screen 6.0

// The following line of code is newly added. Glrotatef (angle, xvector, yvector, zvector) is used to rotate objects around the axis. This is a very useful function. Angle is a number used to specify the rotation angle (usually stored in variables ). The xvector, yvector, and zvector parameters are used to describe a vector to specify the rotation axis of an object. If you use a value like (, 0), you will describe a vector with a length of 1 unit pointing to the right along the X axis; and (-, 0) this value describes a vector with a length of 1 unit that follows the X axis but points to the left.

To better understand the rotation of X, Y, and Z, here are some examples ......

X axis-you are using a saw, and wood passes through the center of the saw knife. The saw blade quickly rotates on the X axis, and the tooth seems to be cut up or down, depending on the direction of rotation of the saw blade. This is similar to rotating an object with the X axis in OpenGL.

// Y axis-imagine a tornado hangs in the wilderness. The center of the tornado is on the Y axis, and the ground it is blowing and fragments are spinning around the Y axis (the center of the tornado) from left to right or from right to left. This is similar to rotating an object with the Y axis in OpenGL.

// Z axis-you are looking at a rotating fan, and the center of the fan is facing you. The fan blades rotate around the Z axis, clockwise or counterclockwise. This is similar to rotating an object in OpenGL with the Z axis.

// Therefore, in the following line of code, if rtri is equal to 7, we will rotate 7 degrees on the Y axis (from left to right ). You can try to modify the code so that the triangle rotates simultaneously on the X and Y axes. Note that the rotation is based on the angle. If the rtri value is 10, we will rotate it 10 degrees on the Y axis.

Glrotatef (rtri, 0.0f , 1.0f , 0.0f ); // Rotate the triangle on the Y axis (new)

//Rtri is not declared here,Declare rtri firstTo achieve dynamic rotation, add rtri + = to the drawing function. 0.2f ;Or rtri-= 0.14f ;Such statements

// In this simple program, we draw only one triangle. If you want to add another triangle, we need to add three lines of code (three vertices) to the end of the original three lines of code, so that in glbegin (gl_triangles) and glend () there will be six lines of code. There should be a group of three vertices between glbegin (gl_triangles) and glend (), and extra vertices will be ignored. The same principle applies to four edges. If you draw all four edges, to add another quadrilateral, you need to add a group of four lines of code after the original four lines of code. A polygon can be composed of any number of vertices, so there can be any line of code between glbegin (gl_polygon) and glend.

// The first line of code after glbegin sets the first vertex for our triangle. The first parameter of glvertex specifies the X coordinate of the vertex, and the second parameter specifies the Y coordinate, the third one specifies the Z coordinate. Therefore, the three lines of code after glbegin (gl_triangles) Specify the vertex above the triangle, the vertex in the lower left corner and the vertex in the lower right corner. Then, glend () tells OpenGL that there are no vertices. In this way, a closed triangle is complete. In clockwise order, we will draw the back of the Quadrilateral. We can also say that we actually see the back of it. If an object is drawn in a counterclockwise order, it will face us on the front.

Glbegin (gl_triangles); // drawing using triangles(Quadrilateral: gl_quads, Line: gl_lines, Polygon, gl_polygon)

// Set the current color to red (Red brightness is full, no green or blue ). The following code is the first vertex (above the triangle). We will draw it in red as the current color. From now on, if we do not change the current color, we will draw everything in red.

Glcolor 3f ( 1.0f , 0.0f , 0.0f ); // Set the color to red

Glvertex 3f (0.0f, 1.0f , 0.0f); // top

Glvertex 3f ( -1.0f , -1.0f , 0.0f); // bottom left

Glvertex 3f ( 1.0f , -1.0f , 0.0f); // bottom right

Glend (); // finished drawing the triangle

References:

OpenGL tutorial (Lesson 1-4)

Chinese Version

Original Jeff molofee (nehe) http://nehe.gamedev.net/

Nehe@connect. AB .ca

Aman Jiang http://www.AmanPage.com

Chaoyu_JIANG@hotmail.com Aman_JIANG@163.com

QQ: 15852673

Attachment:

Date: 2005-9-27 15:58:35

Author information:

Name: Zhang shenpeng

Occupation: University of electronic science and technology, biomedical engineering sophomore year (05)

Email: zsp747@gmail.com

QQ: 375995667 (not commonly used)

Current Plan: I want to study c ++ in depth and want to learn cross-platform programming technologies such as XUL, XPCOM, and wxWidgets. I also want to study zlib, C and C ++, such as SQLite, are commonly used and used in open-source libraries. They learn how to play movies through the PC or mplayer, and finally write a software to learn English through movies and subtitles, its form is probably similar to "I love back words" + CCTV-6 of "dynamic English". I hope that like-minded people will study with me and make progress together. I also hope that experts will be able to guide me on the way forward.

I want to use Google's "online forum + email list" to achieve mutual communication and cooperation. Thank you for your suggestions.

Outlook on Life: Edison is an idol in his mind. Bill Gates is my current ideal. Programming is my favorite. I am an exclusive celebrity of fashion. My ultimate goal in life is to achieve the interface between the human brain and the computer similar to the "black guest empire". Human and machine are combined into one, so that the mind can communicate freely and there is no limit to memory. The limitations beyond the body are the future direction of mankind, however, there is no hope for a long journey. 3.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.