#### Archived

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

# How to Convert a float value into D3DXVECTOR3?

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

## Recommended Posts

Hi all, I m using Directional Control(1st Person Camera) for my game. I m using float value which indicates the direction of camera and the NPCs like one in the RPG book by Jim. I want to use D3DXVECTOR3 for direction in a particular situation so how can i convert that float value into that vector. Thanks for yours help!

##### Share on other sites
You''ll find it tough to do that... the best you can manage would be to take the vector (0,0,1) and rotate it about the Y axis using your float value. It''ll be 2D, though, not 3D; you''d need two float values to make it 3D.

##### Share on other sites
Hmmm... *pulls out old Algebra II notes from matrix transformations*

x = cos( θ ) - sin( θ )
y = cos( θ ) + sin( θ )

Note that the above deals with clockwise rotations. If you want counter-clockwise rotations you just switch the positive and negative sins making it

x = cos( θ ) + sin( θ )
y = cos( θ ) - sin( θ )

Nope that helps!

Also, if you intend to make it 3D (based on spherical coordinates with a radius of one) I can give you formulas for those too... You can either PM me or post and pray I see it .

Hope I was of some help.

- ms

Edit: my darn theta's turned into s.

[edited by - ms291052 on March 1, 2004 6:01:49 PM]

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633708
• Total Posts
3013468
×