#### Archived

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

# Distance algorithms and procedural textures

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

## Recommended Posts

Hello, this question may seem quite childish, but keep in mind I''m 15 :-) I need to get the distance between two vectors in a 3D space, how would I go about doing that? I know the 2D formula but don''t know how to apply it in 3D. Also, I''ve been doing a bit of research into procedural texturing lately, and have a wealth of information on ''how to go about theorizing about thinking about actually someday possibly pondering'' implementing them into a program (hehe most articles on the net are like this ;-) but nothing really useful. Does anyone have or know of any samples programs (with code of course) that show off how to use them? Thanks for any help!

##### Share on other sites
The distance between any two points in space is the square root of the sum of the difference in the components squared. (components is the wrong word...)

in 2d space:

sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))

in 3d space:

sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1))

Tim

• 11
• 10
• 13
• 57
• 11