Intersecting radii in 3D space
-
Hi all
some years ago SU5 days, I came across a problem requiring the intersection on a circle with a line of fixed length (not a tangent). This proved impossible in SU because as we know a circle is a collection of segments. I was able to do the simple math (on Xcel) and input the 10 digit decimal of the coordinates on the 2D surface. Clearly a very cumbersom procedure but it worked. At the time Ruby came out but I didnt have the time to devote to learning it sufficiently. I guess now there are thousands of you smart guys out there who could whistle up a little plug in to do this seemingly mundane task.
I did go on further to do the math for the 3D space which produced all three coordinates for the exact point. As we all know you have to be exact or your plane wont fill and its downhill all the way after that.
I could replicate the math in pseudo code - simple enough to understand if you knew excel notation and only comes out at about 10 lines of simple algebra
Would any kind soul be interested in collaborating on this as the use of this tool is not at all trivial.
Cheers RobinT
Cheers robin
-
Could you post an image to illustrate what you are looking for.
I can understand the intersection of a segment and a sphere, but it's seems more difficult to see the intersection of a segment with a circle, which in many cases won't have a solution.Fredo
-
This is a trivial math solution but you need to program it in a spread sheet unless some one decides to write a plugin. It can also be done graphically but gets to be a challenge in 3d. This link works for both 3 and 2d. For 2d just set the z to zero. http://forums.sketchucation.com/viewtopic.php?f=323&t=32229. I have it programed in Open Office but have not included the logic for the correct angle based on the principal values and the 5 possible solutions for the 3d case. I'll send if you want but it is very quick to program.
-
The URL to the link for the math solution is in the skp file. Here is the link http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/. The author of this 1992 paper gives a unique brilliant solution that makes it trivial to solve.
-
@mac1 said:
The URL to the link for the math solution is in the skp file. Here is the link http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/. The author of this 1992 paper gives a unique brilliant solution that makes it trivial to solve.
Actually, I remember I used this algorithm in the BZ_Divider extension of BezierSpline. I also took it from Paul Bourke
The source code in Ruby is in BZ__Divider.rb (line 138) in the folder BZ_Dir_14Here is the code I use
def intersect_ray_sphere(p1, p2, sc, r) # Calculate the intersection of a ray and a sphere # The line segment is defined from p1 to p2 # The sphere is of radius r and centered at point sc # There are potentially two points of intersection given by # p = p1 + mu1 (p2 - p1) # p = p1 + mu2 (p2 - p1) # Return FALSE if the ray doesn't intersect the sphere. # Credit to Paul Bourke (1992)- see http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/ dp = Geom;;Point3d.new tolerance = 0.001.cm dp.x = p2.x - p1.x dp.y = p2.y - p1.y dp.z = p2.z - p1.z a = dp.x * dp.x + dp.y * dp.y + dp.z * dp.z b = 2 * (dp.x * (p1.x - sc.x) + dp.y * (p1.y - sc.y) + dp.z * (p1.z - sc.z)) c = sc.x * sc.x + sc.y * sc.y + sc.z * sc.z c += p1.x * p1.x + p1.y * p1.y + p1.z * p1.z c -= 2 * (sc.x * p1.x + sc.y * p1.y + sc.z * p1.z) c -= r * r bb4ac = b * b - 4 * a * c if (a.abs < tolerance || bb4ac < 0) puts "No solution" return 99999.9 end mu1 = (-b + Math.sqrt(bb4ac)) / (2 * a); mu2 = (-b - Math.sqrt(bb4ac)) / (2 * a); mu1 end #Note; I only need mu1 in the BZ Divider problem.
Then once you have
mu1
andmu2
, and assuming they are valid, you can compute the intersection points as
pt_inter1 = Geom.linear_combination 1.0 - mu1, p1, mu1, p2
pt_inter2 = Geom.linear_combination 1.0 - mu2, p1, mu2, p2Fredo
-
Hi guys
Im sure we all agree the math is the easy bit and I programmed it into Xcel to give the 3D coords - fine, but you have to input them to su to 10 decimal places to get fully coherent filled planes and accuracy - very tedious.
In case I didnt explain myself properly, just try constructing a 2D
d triangle with 3 unequal side say 1, 2 , 3you wont manage it in SU by construction but you can calculate the point of intersection but to 10+ decimals
then go to the 3D case where you construct a tetrahedron all with unequal sides
I will look at the other stuff posted in the next couple days
cheers new year thingy
-
@robint said:
Hi guys
Im sure we all agree the math is the easy bit and I programmed it into Xcel to give the 3D coords - fine, but you have to input them to su to 10 decimal places to get fully coherent filled planes and accuracy - very tedious.
In case I didnt explain myself properly, just try constructing a 2D
d triangle with 3 unequal side say 1, 2 , 3you wont manage it in SU by construction but you can calculate the point of intersection but to 10+ decimals
then go to the 3D case where you construct a tetrahedron all with unequal sides
I will look at the other stuff posted in the next couple days
cheers new year thingy
btw
this all started for me when I tried to construct a tetrahedron (12 pentagons forming a spherical shape one of the pythagoras perfect solids)
starting from a simple pentagon shape as the base, you then make 5 other equl shapes joining the base sides. Then you have to fold them upwards like a tulip until the touch their sides - try it in SU
you really do need a ruby plug in to find the points of the intersection of circles and spheres in 2 and 3D space because as we know the circle in only polygon with a lot of sides - an approximation to a circle and even with 999 sides its still not accurate enough for SU
cheers Robin
-
Well, with some little trick and using the golden section, you can make a perfect tetrahedron... But of course for us, poor SU users a real circle guide tool would be the ideal.
-
@gaieus said:
Well, with some little trick and using the golden section, you can make a perfect tetrahedron... But of course for us, poor SU users a real circle guide tool would be the ideal.
yes indeed you can get coords by geometrical calcs, there is a whole raft of interesting surds involving root 3
I can mail these to you if you want brain damage.
I did manage to make a perfect tatrahedron in SU but it was very tortuous
I can provide the math in pseudo code (like excel)
but I cant yet manage ruby, but from the little i know its perfectly possible and the tool would be simple to use
simply define the origin of the radii (by clicking a point or entering the coords) then enter the radii length, then display a crosshair point on the screen space, then draw in the lines to connect origins to the points and SU isn then happy
wish wish
robin
-
In these two topics this problem in although 2D is adressed and some posibilitys and ruby solutions are given.
http://forums.sketchucation.com/viewtopic.php?f=323&t=10140 http://forums.sketchucation.com/viewtopic.php?f=323&t=19457Greetings,
Bep van Malde
-
@jim4366 said:
This is one way to make a tetrahedron from scratch. Without a plugin.
It seems that if the angle resolution is 1000 segments per quarter circle or better, it works.
Same basic idea folding up a pentagon will make a dodecahedron.Using a drawn technique will always give some inaccuracy - although 1000 segments will often give a good enough result!
Here's the mathematical way...
The height of a tetrahedron with sides 1 unit long is 0.8164965809 units.
This is 'simple' similar-triangle + Pythagoras way, with lots of sqrt(3) etc: see below...
Draw the tetrahedron as a flat 2d shape scaled so the sides are 1 unit long.
Draw the 3 intersecting lines from apex to mid-point of each side.
Erase unwanted bits.
Move Tool with nothing selected pick 'center' - which will be the apex when relocated.
Pick the Vertex at the center and move up in blue [z] constrained with Shift-key.
Type in 0.8164965809 [=(sqrt(2.6666666666667))/2].
The tetrahedron is now almost complete.
Draw over an edge to make the base-face form.
Use 'reverse' on any face so it's 'out' and then use 'orient' so all other faces match.
Treble click to select all, make a Group of it.
Edit the group and use the Tapemeasure tool to pick two Vertices [these are currently 1 unit apart] and type in the desire size for the sides of the final tetrahedron; confirm when warned and the whole group is rescaled to that side-size...
Done.
Advertisement