#### Archived

This topic is now archived and is closed to further replies.

# multiplying D3DVECTORS

This topic is 5981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m making a collision detection system in D3D. This involves calculations such as : D3DXVECTOR a,b,c; a = b*c; My compiler (MS Visual C++) gives me errors, saying that struct_D3DVECTOR does not define (* and =) as operators, or give an acceptable conversion. (errors C2679 and C2678). The "=" problem could be solved my making my own vertex class/struct, "MyVector", and making the constructor like this: MyVector(int). (don''t understand it, got it from MSDN library). Is there a similar way I can make multiplication work? Also, I''ve seen equations where someone will make a float = the Product of 2 Vectors - a float: float a,d; D3DXVECTOR P,N; a = P*N-d; Even if * would work, how can a float equal the product of 2 D3DVECTORs, when D3DVECTORs have x, y and z members, plus a whole lot of other variables I''m not using. BTW, it doesn''t work with D3DXVECTOR3 either. The system I''m making is very similar to this one: http://www.gamedev.net/reference/articles/article1026.asp Thanx Proceeding on a brutal rampage is the obvious choice.

##### Share on other sites
Um, you can't multiply two vectors. A vector by a scalar yes. You can do the cross or dot product. But multiplying? No.

If "they"'re doing float = vec1 * vec2 then they've overloaded the "*" operator to work as a dot product which gives you (x1x2 + y1y2 + z1z2).

If you don't know basic vector math then I don't think you're quite ready for a collsion detection system. CD is the toughest thing you'll ever do in game programming, I reckon.

- seb

Edited by - bsxrider on February 7, 2002 7:30:56 PM

##### Share on other sites

First, bsxrider, yes and no. You can multiply a ''vector'' by ''vector''; remember, vector is only a special case of matrix. Though, result will be scalar. (something like vec_a = vec_b * transpose(vec_b) , using non mathematical notation ) ...

Then. Amish;
You probably want either cross- or dotproduct; probably latter, considering you''re trying to do collision detection. D3D defines
DotProduct and CrossProduct methods; use them. Of course you have to #define D3D_OVERLOADS before including d3d.h for these to work...

D3DVECTOR a,b,c,d;float f;...a = DotProduct(b,c)*f - d;

##### Share on other sites
In my mind a vector is always a single column. I''m aware that transposing it would make multiplication but then it''s a 3x1 matrix, not a vector.

- seb

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631435
• Total Posts
3000056
×