Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to quickly position parallel lines next to the middle one

Author
Message
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 28th Dec 2012 22:42
I've been trying to figure out how to best place parallel lines next to the main middle one for the past few days with no luck. Here's the function code I have so far:



As you see with the code, I am trying to create a function that places 2 parallel lines next to the main one in the middle while maintaining equilateral distance from the middle line.

I may have to provide a picture to show exactly what I want, but try to imagine a long box has it's 2 long sides stay parallel to the center of the box and keeping the same distance from the center of that box.

Home is where my souped-up computer is...
The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 29th Dec 2012 03:15 Edited at: 29th Dec 2012 03:22
There are an infinite number of solutions so you need to provide us with more information, you don't use the z coordinate in your calculations?

If you think of the master line as a rod through the center of a cylinder then all lines laying on the surface of that cylinder are equal distance from the master line, so which lines do you want?.

JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 29th Dec 2012 04:24
let me try it ascii-wise

m=middle line

p=parallel line







see what I'm saying? the middle line is easy enough to do. It's just a point a-to-b coordinate set. But the other 2 need to keep equal distance from the middle and proper angle translation like a rotating box would. Except that a box in DBPro, wont do 3d coordinated.

As far as the "z" axis is concerned, I forgot about that. I would need to take that into account as well.

If this doesn't clear things up, then I'll do an animated GIF to show what I would like to do.

Home is where my souped-up computer is...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Dec 2012 04:40 Edited at: 29th Dec 2012 04:44
Quote: "If this doesn't clear things up, then I'll do an animated GIF to show what I would like to do."
Please, please no, don't do that; if you had to go so far for something so simple you'd make me feel retarded. lol.

You seem smart enough to figure out the code, so here's the english. Work out the angle from point A to B using Atanfull). You will also need the distance.

Add 90 degrees to you original angle; then set your outer starting point at your thickness distance. Do the same in the other direction by subtracting 90 degrees from your original angle.

Now draw all three lines in the given direction from their individual starting points.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Dec 2012 09:32
If you're ignoring Z at the moment, then I'll just do it in 2D for ya.

Specify the coordinates of the middle line and the distance you want the parallel lines to be from the middle. The function will draw the middle line in red, and the other two parallel lines in white both of equal distance from the middle and match the length of the middle.

For the demo, mouse buttons will change the distance of the lines, move mouse to change ending point of middle line.



"You're not going crazy. You're going sane in a crazy world!" ~Tick
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 29th Dec 2012 17:37
Phaelax, they don't call you the 'Silver Codemaster' for nothin It's just what I need and works like a charm!

Home is where my souped-up computer is...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Dec 2012 19:42
It just occurred to me that I don't even to calculate the line segments length or form a normalized vector. I can simply calculate the end point the same as I did the starting point, thus dropping the square root function and two divisions.





"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2026-07-07 10:59:22
Your offset time is: 2026-07-07 10:59:22