More help with Math needed
Author |
Message |
Danjen
|
Posted: Thu Jan 11, 2007 8:32 pm Post subject: More help with Math needed |
|
|
Okay, here's what I need help with:
I am making a 3D rendering program from scratch (I'm crazy like that ), and I need to determine the distance between two points with three axes (x,y,z). I need to come up with a formula, and so far I've worked it out to cuberoot ((((x1+x2+x3)/3)**2 + ((y1+y2+y3)/3)**2 + ((z1+z2+z3)/3)**2)/3). I'm not sure if that's what it should be, but the outcome seems reasonable. Also, how would one determine the cubic root of a number in turing? As you can see, I used it in that formula but I'm not sure how to actually get the cube root . Finally, for the 3D engine itself; I heard I have to use (x / z) and (y / z) for something... what specifically? Lastly, what is the advantage of using exported qualified commands over non-exported qualified commands (like Draw.Line and drawline)? Thanks in advance ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Thu Jan 11, 2007 8:49 pm Post subject: RE:More help with Math needed |
|
|
As I recall one would have to use the formula D = sqrt((x1 - x2)^2 + (y1 + y2)^2 + (z1-z2)^2) in order to achieve this. |
|
|
|
|
![](images/spacer.gif) |
Danjen
|
Posted: Thu Jan 11, 2007 9:05 pm Post subject: Re: More help with Math needed |
|
|
Oh ... heh I didn't think it would be that simple actually. ![Surprised Surprised](http://compsci.ca/v3/images/smiles/icon_surprised.gif) |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Thu Jan 11, 2007 11:13 pm Post subject: Re: More help with Math needed |
|
|
you use the (x/z) (y/z) for depth (ie, to add the 3D element).
The advantage to using Procedures and Functions from modules (Export qualified proc/fcn's) is that it introduces you to the idea of modularity, meaning if I asked you where the method Line was, you could tell me exactly where it is; in the Draw Module. With something like drawline() however, you have no idea where the code for it is stored, the best you can do is guess. |
|
|
|
|
![](images/spacer.gif) |
zylum
![](http://compsci.ca/v3/uploads/user_avatars/1689129126468091c334ee0.gif)
|
Posted: Thu Jan 11, 2007 11:36 pm Post subject: Re: More help with Math needed |
|
|
rdrake > your plus in the y portion should be a minus so,
D = sqrt[(x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2]
The division by the z component is for adding perspective which gives the illusion of depth.
You could do cube root in turing by doing ' **(1/3) ' -> ie exponentiate to 1/3. |
|
|
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Thu Jan 11, 2007 11:49 pm Post subject: Re: More help with Math needed |
|
|
zylum @ Thu Jan 11, 2007 11:36 pm wrote: rdrake > your plus in the y portion should be a minus so, Whoopsies, yes, it should be. Editing... wait, I can't... :S. |
|
|
|
|
![](images/spacer.gif) |
Danjen
|
Posted: Fri Jan 12, 2007 10:02 am Post subject: Re: More help with Math needed |
|
|
Ok, so would I use (x/z) and (y/z) in the drawing of the object, like object.X + (x/z) etc? |
|
|
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Fri Jan 12, 2007 10:47 am Post subject: Re: More help with Math needed |
|
|
Danjen @ Fri Jan 12, 2007 10:02 am wrote: Ok, so would I use (x/z) and (y/z) in the drawing of the object, like object.X + (x/z) etc? I recommend you read up on perspective. GameDev.net has many excellent articles, including those on matrices.
Reading up on matrices in general would also be a good idea . |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|