I’ve exhausted the web for this simple yet elusive solution. I have two unrelated points that I would like to find the mid point between. I could draw a line as a guide, then use and SDL line on top of that line with a length of 50%, but the spaghetti mess it makes just to find this makes no sense to me. There must be a super simple method for finding the location between two points.
The mid point between two points is:
var mid_point = (point0 + point1) / 2.0;
Does this help?
Um… this is an expression? I worry the result will not result in translated coordinates.
Else, I will have to extract the XYZ of each point individually and divide each — then feed them into a new point.
You can use the Average component to get the midpoint. Or indeed use an expression. If you want to use the Grasshopper expression language, it will look similar to Dale’s notation, just ditch everything in front of and including the equals sign:
(x+y) / 2 or, I’d probably write
0.5*x + 0.5*y.
Yes, just use an addition component (accepts points) and divide by 2… --Mitch
From Grasshopper, this would look like the following:
If you were writing a C# component, you’d use the code from my prior post.
Here’s another method too… maybe too many noodles for you though.
Oh, it’s less noodles than what I have…
Ken, most arithmetical components like Addition, Subtraction, Average etc. work on many data types, not just numbers. You can use them on numbers, complex numbers, colours, vectors, points, …
Yep, Dale beat me to it… --Mitch
Dale, this… for some reason… worked.
I would have never felt this result was expected. I expected the result to be a jumble of values mashed together.
Well, not really… RhinoCommon is set up to be able to add points and vectors in that way. It simply adds all the X coordinates together, the Y coordinates together and the Z coordinates together and outputs the result as a point or vector. Grasshopper is based on RhinoCommon, as is Python/Rhinoscriptsyntax. You can therefore also add/subtract point3d and vector3d objects in Python scripts.
Sounds promising. However, now that I’m using Dale’s method, I’ve somehow created a paradox.
The idea of finding the point between two other points was that each point moved along a curve.
The base position of the line between these points is unknown — because the points move. The kicker is, the points move based on the length of the line, so the longer I make the line, the further out the points move on their respective paths. So finding the centre of the line is great, but doesn’t help me create a line that is independent of the parameters that created it.
Lets say I have two arcs, and I want to create a line of specific length between these arcs. So I use a Brep Sphere with an intersection value from brep to curve. Now I have two points on two arcs at a set distance between each. Here’s where the fun begins… How can I set the base position of the sphere to the centre of the line that it created? It’s a paradox.
Can you post a definition to help me understand this part of the set up? I’m not following it completely.
Unfortunately I’m not permitted to post any of our work online.
The challenge rests with unknowns. I can’t draw a line if I don’t know the start and end points. I can’t set end points without drawing a line to define where the end points need to be.
Let’s simplify for a moment. If you define a line in GH using only a length value (with a slider), the line base point will be placed at 0,0,0 and have the length you have specified. So it will point upwards and connect with nothing, and that’s all good.
Now let’s say you want the end of the line to connect with the edge of a circle — that is within reach. Now let’s say you want the other end of the line to connect with another circle that is also within reach. Let’s say you set the length of the line so that both ends fall within the distance of each circle. Now, how can you connect these 3 objects without causing serious problems? Let’s now say that we cut the circles in half — so GH doesn’t freak out about which side of the circle it should connect with. How can I arrange things so that the line acts like a pipe that is stuck to each arc — while allowing me to move the pipe or change its length so that the intersecting points can move along each arc. This is the ultimate goal. However this could be done is something I’ve yet to figure out.
Can you make a definition that you can share that shows the same issue? The simpler the better… I’m getting lost in just the verbal description. Maybe this would make sense as a new post too if the mid point question has been answered enough.
I’ll see what I can do.
The question has already been answered but here’s how I usually do it. The last component is “point on curve”.
Please see the attached file.
It’s important to know that the Rod is acted upon as the source of movement.
The purpose of this arrangement is to locate the ends of the rod along the circumference of both circles.
The objective I hope to achieve is to have the Rod change orientation based on points along each circle — while maintaining the centre of the Rod equal distance between the circles. To avoid an inherent issue, the circles are not really needed, and can be replaced by ARCs instead.
pushrod_sample.gh (7.7 KB)
are you wanting to do this?
the rod is positioned where it’s the correct length with the end points being on the circles?
pushrod_jh1.gh (7.6 KB)