3d math coordinate question

Rowboat

Senior member
May 25, 2007
200
0
0
I have a set of 3d points that represent a tube, but I need to reduce the final straight piece by 10mm along the path of the final piece. How do you do that? Anyone know an applet somewhere that can do this?
 

Gibson486

Lifer
Aug 9, 2000
18,378
1
0
wouldn't you just change the one axis you are changing? I"m assuming that the path of the final piece is on the axis.




 

Rowboat

Senior member
May 25, 2007
200
0
0
I wish it were that simple. Unfortunately this isn't homework so it doesn't work out that easy. Maybe the best thing is to figure out how to project that final piece so that it exists in only one coordinate.

I was really hopeing for a website to do it for me though :(
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
How do you want the data to be returned to you? Given a list of (x,y,z) data points that represent the tube, return a list of (X,Y,Z) that should remain?
 

Rowboat

Senior member
May 25, 2007
200
0
0
Originally posted by: TuxDave
How do you want the data to be returned to you? Given a list of (x,y,z) data points that represent the tube, return a list of (X,Y,Z) that should remain?

Yes, the end result should be identical up until the last point.
 

Gibson486

Lifer
Aug 9, 2000
18,378
1
0
Originally posted by: Rowboat
Originally posted by: TuxDave
How do you want the data to be returned to you? Given a list of (x,y,z) data points that represent the tube, return a list of (X,Y,Z) that should remain?

Yes, the end result should be identical up until the last point.

then why don't you just do vector math? I mean, if z is the only change, why can't you just subtact from the z vector?
 

Rowboat

Senior member
May 25, 2007
200
0
0
Originally posted by: Gibson486
Originally posted by: Rowboat
Originally posted by: TuxDave
How do you want the data to be returned to you? Given a list of (x,y,z) data points that represent the tube, return a list of (X,Y,Z) that should remain?

Yes, the end result should be identical up until the last point.

then why don't you just do vector math? I mean, if z is the only change, why can't you just subtact from the z vector?

Sorry, i meant that the set is identical up until the last x,y,z and the end result needs to be x,y,z.

Here are the coordinates (mm)

0 , 0 , 0
31.623 , 4.8514 , 19.9644
67.5894 , -30.0482 , 59.69
92.4052 ,-51.5874, 76.9366
110.5916, -74.4474 ,105.664
125.6284 ,-69.6976 ,142.24

But the line connecting the last two points needs to be 5mm shorter. I have about 20 of these to do so the quickest setup is best. If i could find a formula i could create a spreadsheet to do it etc.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Ok so I think I see what you're doing. So assuming that the tube isn't perfectly aligned in the X,Y or Z axis....

If you have two data points that represent the two end points of the tube and the first data point is the same and the 2nd data point is being moved. I would attempt to "scale the tube" rather than "subtract the tube" length.

1) Calculate the deltaX,deltaY,deltaZ of the two coordinates (subtraction)
2) Find the total length of the tube = sqrt(deltaX^2+deltaY^2+deltaZ^2)
3) Find the new length of the tube (#2 - 10mm)
4) Calculate the ratio of the two lengths (#3/#2)
5) Multiply the delta(X/Y/Z) against the ratio
6) Add back the delta to the first coordinate to get your new coordinates of your final point.

You can easily do this in excel
 

AeroEngy

Senior member
Mar 16, 2006
356
0
0
Originally posted by: TuxDave
Ok so I think I see what you're doing. So assuming that the tube isn't perfectly aligned in the X,Y or Z axis....

If you have two data points that represent the two end points of the tube and the first data point is the same and the 2nd data point is being moved. I would attempt to "scale the tube" rather than "subtract the tube" length.

1) Calculate the deltaX,deltaY,deltaZ of the two coordinates (subtraction)
2) Find the total length of the tube = sqrt(deltaX^2+deltaY^2+deltaZ^2)
3) Find the new length of the tube (#2 - 10mm)
4) Calculate the ratio of the two lengths (#3/#2)
5) Multiply the delta(X/Y/Z) against the ratio
6) Add back the delta to the first coordinate to get your new coordinates of your final point.

You can easily do this in excel

That should work just fine. I was thinking about suggesting something much more complicated because I was envisioning a large set of coordinates defining the 3-D surface of a "tube".

I was going to suggest taking the segment's coordinates apply translational and rotation matrices to align with a primary axis. Then scaling and reapplying the opposite translational and rotation matrices to put it back. Or some other matrix operations involving the unit vector along desired "shrinking" direction and some scale factor. But TuxDave's approach would be much easier for this case..
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: AeroEngy
Originally posted by: TuxDave
Ok so I think I see what you're doing. So assuming that the tube isn't perfectly aligned in the X,Y or Z axis....

If you have two data points that represent the two end points of the tube and the first data point is the same and the 2nd data point is being moved. I would attempt to "scale the tube" rather than "subtract the tube" length.

1) Calculate the deltaX,deltaY,deltaZ of the two coordinates (subtraction)
2) Find the total length of the tube = sqrt(deltaX^2+deltaY^2+deltaZ^2)
3) Find the new length of the tube (#2 - 10mm)
4) Calculate the ratio of the two lengths (#3/#2)
5) Multiply the delta(X/Y/Z) against the ratio
6) Add back the delta to the first coordinate to get your new coordinates of your final point.

You can easily do this in excel

That should work just fine. I was thinking about suggesting something much more complicated because I was envisioning a large set of coordinates defining the 3-D surface of a "tube".

I was going to suggest taking the segment's coordinates apply translational and rotation matrices to align with a primary axis. Then scaling and reapplying the opposite translational and rotation matrices to put it back. Or some other matrix operations involving the unit vector along desired "shrinking" direction and some scale factor. But TuxDave's approach would be much easier for this case..

lol yeah when I first heard the story I thought it was a huge constellation of coordinates that when you connect all the dots it visually looks like a 3d-pipe. I probably would've ended up doing something monstrously complex too.
 

Rowboat

Senior member
May 25, 2007
200
0
0
TuxDave

Thanks so much, that worked like a champ. This project just moved from my "leave it until its forgotten" bin to the "i might do that if i'm bored" one.

edit:

Heh no nothing complex, just trying to get some use out of a 15+ year old cnc machine.
 

drinkmorejava

Diamond Member
Jun 24, 2004
3,567
7
81
So question, what exactly do the final straight peice and the final piece mean. I can assume the straight piece is along the central axis, but otherwise I have no clue wth you're trying to say.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
166
111
www.slatebrookfarm.com
I just put your points into PointPlot3D in mathematica... I don't get it/I can't "see" a tube. (By tube, you mean a cylinder?)

The only thing I could figure was that 4 of those points were down the central axis, and the first and last points represented the outer and inner edges of, well, a tube. But, the 4 points aren't collinear, so that didn't make sense. Just at a glance, 3 of them looked pretty collinear.

(edit: I understand what you said you needed to do, and I would have suggested the exact same thing that TuxDave suggested; although worded slightly differently - find the vector, find the vector length, divide the vector by the vector length to get a unit vector, subtract 10 from the vector length to get the new length, multiply the unit vector by that length, then add it to the next to last point. I'm just not getting the "tube" part.)