Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
661 | ataualpa | 1 | x3d equ 0 |
2 | y3d equ 2 |
||
3 | z3d equ 4 |
||
4 | vec_x equ 0 |
||
5 | vec_y equ 4 |
||
6 | vec_z equ 8 |
||
7 | ; 3d point - triple integer word coordinate |
||
8 | ; vector - triple float dword coordinate |
||
9 | ;----------------------in: -------------------------------- |
||
10 | ;------------------------ esi - pointer to 1st 3d point --- |
||
11 | ;------------------------ edi - pointer to 2nd 3d point --- |
||
12 | ;------------------------ ebx - pointer to result vector -- |
||
13 | ;---------------------- out : none ------------------------ |
||
14 | make_vector: |
||
15 | fninit |
||
16 | fild word[edi+x3d] ;edi+x3d |
||
17 | fisub word[esi+x3d] ;esi+x3d |
||
18 | fstp dword[ebx+vec_x] |
||
19 | |||
20 | fild word[edi+y3d] |
||
21 | fisub word[esi+y3d] |
||
22 | fstp dword[ebx+vec_y] |
||
23 | |||
24 | fild word[edi+z3d] |
||
25 | fisub word[esi+z3d] |
||
26 | fstp dword[ebx+vec_z] |
||
27 | |||
28 | ret |
||
29 | ;---------------------- in: ------------------------------- |
||
30 | ;--------------------------- esi - pointer to 1st vector -- |
||
31 | ;--------------------------- edi - pointer to 2nd vector -- |
||
32 | ;--------------------------- ebx - pointer to result vector |
||
33 | ;---------------------- out : none |
||
34 | cross_product: |
||
35 | fninit |
||
36 | fld dword [esi+vec_y] |
||
37 | fmul dword [edi+vec_z] |
||
38 | fld dword [esi+vec_z] |
||
39 | fmul dword [edi+vec_y] |
||
40 | fsubp ;st1 ,st |
||
41 | fstp dword [ebx+vec_x] |
||
42 | |||
43 | fld dword [esi+vec_z] |
||
44 | fmul dword [edi+vec_x] |
||
45 | fld dword [esi+vec_x] |
||
46 | fmul dword [edi+vec_z] |
||
47 | fsubp ;st1 ,st |
||
48 | fstp dword [ebx+vec_y] |
||
49 | |||
50 | fld dword [esi+vec_x] |
||
51 | fmul dword [edi+vec_y] |
||
52 | fld dword [esi+vec_y] |
||
53 | fmul dword [edi+vec_x] |
||
54 | fsubp ;st1 ,st |
||
55 | fstp dword [ebx+vec_z] |
||
56 | ret |
||
57 | ;----------------------- in: ------------------------------ |
||
58 | ;---------------------------- edi - pointer to vector ----- |
||
59 | ;----------------------- out : none |
||
60 | normalize_vector: |
||
61 | fninit |
||
62 | fld dword [edi+vec_x] |
||
63 | fmul st, st |
||
64 | fld dword [edi+vec_y] |
||
65 | fmul st, st |
||
66 | fld dword [edi+vec_z] |
||
67 | fmul st, st |
||
68 | faddp st1, st |
||
69 | faddp st1, st |
||
70 | fsqrt |
||
71 | |||
72 | ftst |
||
73 | fstsw ax |
||
74 | sahf |
||
75 | jnz @f |
||
76 | |||
77 | fst dword [edi+vec_x] |
||
78 | fst dword [edi+vec_y] |
||
79 | fstp dword [edi+vec_z] |
||
80 | ret |
||
81 | @@: |
||
82 | fld st |
||
83 | fld st |
||
84 | fdivr dword [edi+vec_x] |
||
85 | fstp dword [edi+vec_x] |
||
86 | fdivr dword [edi+vec_y] |
||
87 | fstp dword [edi+vec_y] |
||
88 | fdivr dword [edi+vec_z] |
||
89 | fstp dword [edi+vec_z] |
||
90 | ret |
||
91 | ;------------------in: ------------------------- |
||
92 | ;------------------ esi - pointer to 1st vector |
||
93 | ;------------------ edi - pointer to 2nd vector |
||
94 | ;------------------out: ------------------------ |
||
95 | ;------------------ st0 - dot-product |
||
96 | dot_product: |
||
97 | fninit |
||
98 | fld dword [esi+vec_x] |
||
99 | fmul dword [edi+vec_x] |
||
100 | fld dword [esi+vec_y] |
||
101 | fmul dword [edi+vec_y] |
||
102 | fld dword [esi+vec_z] |
||
103 | fmul dword [edi+vec_z] |
||
104 | faddp |
||
105 | faddp |
||
106 | ret |
||
107 |