Echo #01
31 октября 1996 |
|
Assembler - The image of three-dimensional objects. Fast output point AT X, Y. The procedure of multiplication.
--------------------- Three-dimensional image objects. --------------------- Everyone saw the Slovak demo ECHOLOGY. Is not it cool? (We are talking about its 3D PART). Now I try to tell how to do it. 1) you need to write a quick conclusion point, because he has a bigger impact on the final performance the program; 2) then write a quick conclusion entire length (or rather the vector) speed of this procedure in second place in importance; 3) Do what you want ... (With jokes I napryazhenka!) I will cite a few figures to which we should strive to write the output point and a segment: Point - about 100/110T Point in the interval 200T I have got these results, but it does not mean that can be done faster ... Now we must do in order to coordinate the sequence was connected segments (those you'll get a stable position object on the screen, such sustained, that even the sequence of commands di: halt does not erase a screen fruits of your labor). In the end, you still tired of footing the monitor ... ugh! ... screen, and ought to his povertet (or twist). Ah! I forgot to remind that in 3DGRAPH (well, this is where the three axes: X, Y and Z), each point is given by three coordinates. And now I will smite you all, stating that the derivation for screen 3D-points should be used only two coordinates: X and Y (not Is it true you hit?). Okay, back to the question of turns (and bloat) figures. Let me give a few formulas that I use (and probably someone else): a) rotation by an angle (a) around axis X: X '= X; Y '= COS (a) * Y-SIN (a) * Z; Z '= SIN (a) * Y + COS (a) * Z; b) rotation by an angle (a) around axis Y: X '= SIN (a) * Z + COS (a) * X; Y '= Y; Z '= COS (a) * Z-SIN (a) * X; c) rotation by (a) around axis Z: X '= COS (a) * X-SIN (a) * Y; Y '= SIN (a) * X + COS (a) * Y; Z '= Z; I hope that you will not be before output figures count its position, and pre-create the table (if the object is drawn segments, the table is better do not store the coordinates of the vertices, and vector, so it will be faster ...). How to store a number or vector in the table? Personally, I use this method: the number of modulo unlikely to be more than # 7F, then the seventh bit will be a milestone: 1 number is negative, 0 positive. For a vector we need to know displacements and their directions. Ie vector will hold in memory 2 bytes (first byte offset and the direction of axis X, the second - on Y). On the question of errors. When I wrote a three-dimensional effect, it just did not get a heart attack, seeing my lovely cube in 2 seconds of rotation has turned in the wrong Allen (also a good effect!) It turned out that the whole point of error, which was in the calculations. I can give you a few tips: 1) All calculations are performed in calculator ROM (or, in his); 2) the intermediate results Keep a 5-byte format; 3) rounding of be carried out only for those numbers that are entered in the table, but their real value left for subsequent calculations; I speed up the table for a cube of 200 of its provisions, using ROM, about 40 seconds. I roughly know what to do that figure is not only rotate but increased and decreased during the rotation, but he has not yet do (laziness). P.S. If This is all ably filtered, then from it can be pulled some useful information mation. P. P. S. Almost everything I RASSC Hall of 3D-graphics you shall see babe in our DISTURBANCE Demo, which will soon long zhno out (or maybe not exit). DISTORTER (Demkovich Ivan) ADIA SOFT, Brest, 08.27.1996 224017, Brest Moscow, 267/3-47 Call (0162) 411655 +------------------------------+ Comment VfNG / NHG: That's ADIA poprikalyvatsya. Article as a whole is interesting, something really pull possible. I will cite, in addition several useful things: 1) rapid withdrawal point AT X, Y: LD H, D; 4 LD E, (HL); 7 INC H; 4 LD A, (HL); 7 LD L, B; 4 INC H; 4 OR (HL); 7 LD C, A; 4 INC H; 4 LD B, (HL); 7 LD A, (BC); 7 OR E; 4 LD (BC), A; 7 Only 70 cycles. What-where to be on vhodene say that was interesting. Nobody said that it is this procedure must be used when output. This is so for a workout. 2) Classroom protsedurka multiplication (Much like a sticking ECHOLOGY): H-number 1; E-number 2; L, D = 0; ADD HL, HL JR NC, L1 ADD HL, DE L1 ADD HL, HL JR NC, L2 ADD HL, DE L2 ADD HL, HL JR NC, L3 ADD HL, DE L3 ADD HL, HL JR NC, L4 ADD HL, DE L4 ADD HL, HL JR NC, L5 ADD HL, DE L5 ADD HL, HL JR NC, L6 ADD HL, DE L6 ADD HL, HL JR NC, L7 ADD HL, DE L7 ADD HL, HL JR NC, L8 ADD HL, DE L8 Output - the HL result. Here, wisely applied the decomposition of numbers into binary factors. I strongly advise to look into This protsedurke! 3) The numbers in the interval [0, 1) recommend multiplying by 256 and in a format to store. If you necessary, for example, to multiply the sine number on any crap, then protsedurkoy previous one is done as: H-sine * 256 (if it is equal to 1 and you still going to him something to multiply, then ...), E-this same crap at the output: in H integer, L the fractional part of the result. 4) The angles are much nicer to consider not in degrees or radians, and 1 / 256 full twist. 5) Use of calculator ROM-barbarism. For intermediate research is still here and there, but no more. Work with your own, cleverly written procedures gives the acceleration factor of 10-20 compared with Rom. Error Actually, not so scary. Quite enough accuracy to 1 / 256. 6) With zoom in / out, too, is simple: multiply the X and Y ??? / Z (again, think of yourself!). All I'm here ponapisyval, In no case can not be used directly in the oak. Here you some ideas, hints: think. We can not say, of course, that it is my highest achievement (Like any normal person their secrets so just will not tell). Incidentally, my conclusion is chertilochke 22-110 (Mean 40) beats ... And in general in the scriber point output should go faster than just from goosey. Can do better? +------------------------------+
Other articles:
Similar articles:
В этот день... 21 November