New translate request?
-
I believe Didier devised this brilliant bit of code, I have been using it mainly because the new point it creates are not static and works in any 3d orientation.
# creates a new point from p1 in the direction of p2-p3 with length d # params are Point3d, 2 vertices, a length, returns a Point3d def translate(p1, p2, p3, d) v = p3 - p2 v.length = d trans = Geom;;Transformation.translation(v) return p1.transform(trans) end
I'm not skilled enough in Ruby to develop a similar new bit of code. So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.
Tia!
-
@tomot said:
So I'm hoping someone here can help me. I would like this new bit of code help me find a point p3? given the "dotted" distance which lies outside and inline with p1 and p2 The attached pic. illustrates what the current code does, and what I'm requesting.
Tia!
Assuming the dotted distance is <
dd
> and you name p3? by p4, just usep4 = p2.offset p3.vector_to(p2), dd
The line oriented vector is
p3.vector_to(p2)
, and you just offsetp2
by the distancedd
.Fredo
-
@unknownuser said:
Assuming the dotted distance is <
dd
> and you name p3? by p4, just usep4 = p2.offset p3.vector_to(p2), dd
The line oriented vector is
p3.vector_to(p2)
, and you just offsetp2
by the distancedd
.
FredoThanks Fredo6: I see my use of English has failed me again My p3? would actually become the new location of p3 similar to the original code starting with a new name to distinguish it it for other code snippets hence the first line would start something like this
def translate_extend(p1, p2, p3, d)
followed by the technical stuff, and so I can reuse it again in other places where required in any other script.
-
Then use
p3 = p2.offset p2.vector_to(p1), d
This gives the point p3, which at distance d of P2 in the direction of p1
Fredo
Advertisement