The basic questions about graphics mathematics are the process of rotating along any axis or rotating the coordinate system.

Source: Internet
Author: User

1.Basic graphics problems (15Points)

In the right Coordinate SystemAInner,PThe coordinate of the point is(1, 1, 1), mCoordinate is(3, 4, 5), nCoordinate is(6, 7, 8)

A)PleasePPoint 1MPoint as the center, aroundYAxis rotation30°.ZAxis rotation-- 60Coordinates after °Q

B)PleasePPointMnAxis, rotation-45° Coordinates obtained.

C)HypothesisBCoordinate System isAThe coordinate system is obtained by performing the following steps:

I.BypassXAxis rotationα°

II. Z axis rotation β °

III.Pan again

ForBAny point in the coordinate system(X, y, z)InAThe coordinate value expression in the coordinate system.

 

1.The answer is as follows:

 

A)First, translate the coordinate systemMPoint,ThenY, zRotate the axis and then pan it back.,Matrix left multiplication Vector,The formula is as follows::

PanMPoint translation matrix:

BypassYAxis rotation30Degrees

BypassZAxis rotation-60Degrees

Pan the coordinate system to the origin

Composite rotation matrix

 

B)Let's talk about the method.,The formula is also given.,

Medium, MnVector is known(3, 3, 3)IfMPoint is the origin, MnIsZCreate a local coordinate system for the Axis,ThenPPoint transformation to Local Coordinate System,ThenMnAxis rotation,ChangeXYZIn the coordinate system..

 

(1)The local coordinate system is obtained as follows::

VectorMnOfXComponent is(1, 0, 0 ),AvailableMGIndicates,VectorML = Mn * Mg,VectorMk = ML * mn ,*Indicates the cross multiplication..

 

ML = Mn * Mg = (0, 3,-3 );

Mk = ML * Mn = (18,-9,-9 );

 

Take VectorMK, ML, MnAxis,ToMPoint is the origin to create a coordinate system,MatrixMIndicates

M

 

 

MRepresents a coordinate system,At the same timeMRepresents a set of linear irrelevant base Vectors,SetMVector unitization of the three columns,Get

(2)PPoint, EThe concept of linear correlation and independence can be used to derive the mutual transformation between coordinate systems.:

P = (1, 1, 1)Representative VectorOPInECoordinates in, Representative VectorOPIn Coordinates in

Ep = P;

= P;

Because Indicates the orthogonal unit vector group, so its inverse is equal to its transpose

Then= * P = * Ep = * P;

WhileP = *;

 

(3)First translate coordinatesMPoint, and thenPPoint to local coordinate systemMnRotate, and thenPPoint is transformed to the original coordinate system, and then the coordinate system is translated to the origin to obtain the result.

The composite matrix is as follows::

The composite matrix is as follows::

R = *** t

 

C)The idea is as follows: each transformation forms a new coordinate system. The three components of the new coordinate system can be listed in a linear form using the old coordinate system, the output coefficient is a rotation matrix or a translation matrix. According to the question, the output coefficient is as follows:

 

 If the Coordinate SystemBUse a MatrixBThe three column vectorsB = A *** T;

ForBAny point in the coordinate system(X, y, z)And its vector usagePInACoordinate value in the coordinate systemPPush and import expressions:

AP = P;

B = P;

ThereforeAP = BGetP = * B = * A *** T = *** T *.

 

2.Basic Problems of Image Processing (15Points)

Write 1ProgramAchieve simple image scaling, assumingRgb24Format ImageAThe width isWa,The height isHa,Save inChar *TypeBuffer, Write a function to scale it to the width isWB,The height isHB. Independently designed interfaces andCode.

2.The answer is as follows:

Answer::The digital image transformation consists of two steps: Step 1, space transformation, specifying the pixel moving method, which is related to the pixel storage method, step 2, and interpolation method. Determines the accuracy of image transformation. Common methods include neighbor sampling, bilinear interpolation, and cubic convolution. For the sake of simplicity, this paper uses the neighbor sampling method.

If the target pixel is derived from the source pixel, one pixel may correspond to multiple pixels, or multiple pixels correspond to one pixel. Therefore, reverse conversion is required, that is, the source pixel is derived from the target pixel cycle.

 

The nearest neighbor sampling method means that when the source pixel is derived from the target pixel, the derived floating point number can be obtained directly rounded up.

 

RectangleWB, Hb,ScaleWa, haThe scaling matrix of is

S =Where= Wa/WB, = HA/Hb;

Color can be accessed using a continuous one-dimensional array and a tool class.,As follows:C ++Language implementation

 

The details are as follows:

//For simplicity,Class-based interpolation,Therefore, the image effect is not accurate enough.,If you want

//More accurate,Bilinear interpolation or other methods can be used.,For24Color Table items are not considered.

Class cdibbitmap: Public cobject

{

Public:

 

Cdibbitmap ();

Virtual ~ Cdibbitmap ();

Public:

Void bitscale (float X, float y, int cy, CDC * PDC); // X, YIs the scaling factor

};

 

Cdibbitmap: cdibbitmap ()

{

}

 

Cdibbitmap ::~ Cdibbitmap ()

{

}

 

 

Void cdibbitmap: bitscale (INT wa, int ha, char * buffer, int WB, int Hb, char * bufferdest )//

{

 

For (INT I = 0; I <Hb; I ++)

{

For (Int J = 0; j <WB; j ++)

{

 

Int WA = floor (WA/WB * j );

Int HB = floor (HA/HB * I );//Directly integer,Interpolation using the Nearest Neighbor Method

 

* Bufferdest ++ = * (buffer + 3 * Wa + HB );

* Bufferdest ++ = * (buffer + 3 * Wa + HB + 1)

* Bufferdest ++ = * (buffer + 3 * Wa + HB + 2)

}

}

}

 

3.Image processing Programming

A)UseC ++Set oneImageClass, including basic attributes essential for an image

B)WriteLoadImageTo readBMPImage, required accordingBMPThe header definition obtains the correct image information by analyzing the file header.BMPRead functions.

C)Correctly display the image in the interface (Win32OrMFCYes)

D)Achieve image scalingAlgorithmAnd the scaled image is displayed.

3.The answer is as follows:

 

A:A)For simplicity, just consider24Bitmap, no color table item.

B)SeeSource code.

C)Directly use functions to extract images fromBufferRead and use functions to scan the screen. Scan row alignment is mainly considered.

D)For the sake of simplicity, we only need to consider rounding and do not use complex interpolation algorithms. For details, see the code.

ReadBMPFileCcreadbitview: onread (),Function, file name:Da.bmp,Shrink simultaneously


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.