|
-
Apr 17th, 2001, 08:30 PM
#1
I have the endpoints to a 3D line, and I would like to be
able to get the x and z coordinates, after setting y to 0.
Any suggestions? If someone knows the formula for a 3d line, please post =). Thanks.
Z.
-
Apr 18th, 2001, 05:20 AM
#2
Banned
Try the vectorial equation.
(x,y,z) = (x1,y1,z1) + k*(u1,u2,u3) with k as a real number
(x,y,z) is a point of the line which we do not know
(x1,y1,z1) is a point of the line which we do know
(u1,u2,u3) is the vector of the line, which give us its direction and which we know.
x=x1+k*u1
y=y1+k*u2
z=z1+k*u3
I could write more, but I'm at school at the moment. I hope this helps in some way. Sorry for the possible misspelling:
-
Apr 18th, 2001, 05:30 AM
#3
transcendental analytic
by setting y to 0, i suppose you don't mean a projection of the line in x-z plane. Do you want to preserve the length?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 12:03 PM
#4
What I want to do is to transform a mouse click into 3D world space at 0.0y(the ground). It makes sense that you could just create the line, and "trace" along it until you get to 0.0y, and there are your coordinates. Thanks much, and any more help is greatly appreciated!
Z.
-
Apr 18th, 2001, 12:36 PM
#5
transcendental analytic
suppose the line is V1-V2, where V1 is above the surface Y=0 and V2 is below. the intersection point is positioned proportional to the absolute of Y components of V1 and V2. So |Y1|/|Y1-Y2|*(V1-V2)+V1 is the intersection point
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 12:46 PM
#6
Ill try that out kedaman =). You rock! Ill let you know how I make out in an hour or so.
Z.
-
Apr 18th, 2001, 12:51 PM
#7
transcendental analytic
hehe
oh and btw, in case they are both above or below the surface, the ratio will be above 1 and you will find the supposed intersection (as if the line was a ray)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 03:29 PM
#8
Erg. The formula you gave me didn't work. It gave me some pretty whacked out numbers (ie, i clicked in the vicinity of (0,0,0), and i got some 6 digit number back in one of my values. Earlier though, i was thinking of ways to do this, and i though of getting the line points, and then just disregarding the y values, and convert it to 2D (looking straight down) using z as a replacement for y. Then, use a line system, with the perpendicular to the line, and where they corss, SHOULD be the intersection. My only problem is that I can't figure out how to implement it. Any suggestions, comments, help? Please? =).
Z.
-
Apr 18th, 2001, 03:41 PM
#9
transcendental analytic
and on what values did you get whacked numbers?
btw, if any y components is too close to z you might get inprecise coordinate or even overflows. How does your implementation look?
I'm a bit uncertain about what you were suggesting now.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 04:20 PM
#10
If you imagine the scene as a cube from above, then draw the line through that. Then squash it flat, by disregarding al of the y values. Then, draw a line that is perpendicular to the actual line (negative reciprocal slope), and where they intersect, that should be the 0.0y intersection.
Z.
-
Apr 18th, 2001, 04:33 PM
#11
transcendental analytic
that doesnt sound correct to me
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 05:09 PM
#12
Here is the way that I implemented your solution kedaman, maybe i got it wrong:
Code:
vecEnd.x = abs(tVec1.y) / abs(tVec1.y - tVec2.y) * (tVec1.x - tVec2.x) + tVec1.x;
vecEnd.z = abs(tVec1.y) / abs(tVec1.y - tVec2.y) * (tVec1.z - tVec2.z) + tVec1.z;
tVec1 and tVec2 hold the endpoints, vecEnd should be the world coordinate.
Here is the result, after clicking somewhere near 0,0:
Code:
- vecEnd {...}
x 262036.
z 1.20112
Thanks for all of your help so far =).
Z.
-
Apr 18th, 2001, 05:15 PM
#13
transcendental analytic
looks correct to me, but when you say 0,0, what is the y coordinates on tvec1 and tvec2
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 05:17 PM
#14
tVec1.y = 131028.(dunno what comes after this dot, but its there)
tVec2.y = -11.32
Z.
-
Apr 18th, 2001, 05:21 PM
#15
transcendental analytic
that gives a ratio of 0.999913613715334, your x coordinates must be very far apart then?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 05:29 PM
#16
Dont i feel dumb. typo while assigning the screen coordinates, before getting the endpoints. I assigned the screen x to the tVec1.x. After fixing that, it came out with a z of 0.4, and an x of -18.2.
Z.
-
Apr 18th, 2001, 05:35 PM
#17
transcendental analytic
so you've got everything working now?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 05:39 PM
#18
The values look a whole lot better to me, but they are still off a bit. The z, is VERY close, but the x is still off, by almost 20. thanks for helping me so much, and if you think of anything, please let me know =).
Z.
-
Apr 18th, 2001, 05:43 PM
#19
transcendental analytic
if you give me all values at once, i'll see you get correct results
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 18th, 2001, 05:51 PM
#20
ok, here goes.
Screen Pos: x = 154, y = 381
Endpoint1: x = -11.4650, y = 9.12081, z = 0.214873
Endpoint2: x = 0.442616, y = -10.4461, z = 4.99706
Intersect Coordinates: x = -17.0155, z = -2.01427
The 3D coordinates i was aiming at were -0.5, -0.5
Thanks much.
Z.
-
Apr 18th, 2001, 05:52 PM
#21
Oh, and kedaman. You are most definately the best =).
Z.
-
Apr 19th, 2001, 05:53 AM
#22
Thank you kedaman =). That did the trick. You ROCK! =). Now my day will be perfect. Thanks so very much =).
Im very proud of my avatar =). It uses my old one too =).
Z.
PS: THANK YOU =).
-
Apr 19th, 2001, 06:12 AM
#23
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|