Drawing a parallel line
-
Hi
I want to be able to supply a line and a width to a method and have the method draw a rectangle based on that line and a parallel line that width apart.
I want to use this for drawing the footprints of walls that may be sloped or paths on sloped terrain etc.
My question is what is the precise transformation required to get this second parallel line? Im considering working either with points perhaps using the offset method or with vectors. Either way I need to figure out the right transformation.
One thing Im thinking is that a perpendicular line to the original line of length 'width' would be a useful vector. However when I try and calculate that I cant figure out which plane Im meant to rotate in to get it(is it multiple planes)!
One problem with perpendicular lines is i can see that there are at least two perpendicular lines to any one line ignoring direction.
thanks heaps for any help!
Paul
-
You should be able to steal code from the box.rb example, since it creates a rectangle before it pushpulls it into a box.
-
If you are drawing these double lines on a 'surface' then picked-point at
point1can be used to return the best face below it - get theaxis=face.normal...
If it's not on any face or you want it flat thenaxis=Z_AXIS
Then next picked_pointpoint2needs to be on that face, so get it's initial value and then use
point2=point2.project_to_plane(face.plane)
or if it's to be 'flat' usepoint2.z=point1.zinstead so it's level withpoint1...
This gives you the first edge
edge12=entities.add_line(point1,point2)
To make it's offset 'clone'...
Assuming 'width' is the offset required.
point3=point1.offset(edge12.line[1],width)
rotate it into place...
tr=Geom::Transformation.rotation(point1,axis,90.degrees) point3.transform!(tr)
get the other end point
point4=point3.offset(edge12.line[1],edge12.length)
and then draw the offset edge
edge34=entities.add_line(point3,point4)

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement