Jump to content

Best way to divide a diagonal straight line into 30 equal segments?


Recommended Posts

There had been a bunch of such questions before, just search the forum for similar topics.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

I checked those out, but I couldn't figure out how to use those to help me. And I did search. The good news is, I think I figured it out, so will post my solution for anyone else who happens upon this topic!

The trick is to use a long skinny rectangle instead of a line.

  • make a long skinny rectangle (like 4 inches by .02 inches) that goes from the start point to the finish point (use the mid points of the short sides)
  • duplicate the rectangle (select it, control-c, control-v)
  • change the rectangle's height or width (whichever is greater depending on it's orientation) to 1/Xth of what it was, where X is the number of segments you want.
    • you can do this in Designer quite easily but just adding a "/30" (for example) to the measurement you want to divide in the transform box.
  • control-j to power duplicate
  • move the duplicate such that the start of the new skinny rectangle touches the end of the one we duplicated, head to tail.
  • Hit control-j a bunch more times until you get all the segments you need.
  • delete the original long skinny rectangle (unless you still need it for something else).

This will give you X perfectly divided straight line segments where you once had a single line (well, technically, skinny rectangle, but that's fine.)

Woot!

Link to comment
Share on other sites

4 hours ago, panjakrejn said:

This will give you X perfectly divided straight line segments where you once had a single line (well, technically, skinny rectangle, but that's fine.)

You can create diagonal lines instead of skinny rectangles using a slightly modified version of your method:

  1. Make & duplicate a rectangle the same way as in your first & second steps.
  2. Change both the width & height of the duplicate using the same "w/x" & "h/x" Transform panel method you used.
  3. Move this reduced size rectangle to one of the corners of the original one.
  4. Switch to the Pen Tool & use this smaller rectangle to draw a line from one of its corners to its diagonal corner.
  5. Duplicate this line & move it diagonally so it touches the end of the first one, head to tail.
  6. Power duplicate (control-j) to create the remaining diagonal lines, stopping when the last duplicate touches the opposite corner of the original rectangle.
  7. You can now delete or hide the two rectangles, leaving only the diagonal lines which can then be grouped if you want individual lines or selected & joined if you want one long multi-segment line.

30 diagonal lines.afdesign

All 3 1.10.8, & all 3 V2.5.6 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
A
ll 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

Well the whole would be sooo... easy with the help of some scripting functions, or some UI based dedicated interpolation & split functionality. Below a simple Python example.

''' Here's a Python example of splitting a line string (x1=0, y1=0, x2=10, y2=10) into 4 equal length 
''' parts with the Shapely geo lib. For the given line the interpolate func determines the splitting points, 
''' which in turn are then passed over to a split func which splits the line at those points. 
''' The result are the 4 lines in this case.

from shapely.geometry import LineString, MultiPoint
from shapely.ops import split

line = LineString([(0, 0), (10, 10)])
splitter = MultiPoint([line.interpolate((i/4), normalized=True) for i in range(1, 4)])
split(line, splitter).wkt
# Result:
# 'GEOMETRYCOLLECTION (LINESTRING (0 0, 2.5 2.5), LINESTRING (2.5 2.5, 5 5), LINESTRING (5 5, 7.5 7.5), LINESTRING (7.5 7.5, 10 10))' 

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

3 minutes ago, Lagarto said:

Isn't this a similar case as in this post ...

Yip, it's pretty much the same case, just more segments here.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

55 minutes ago, Lagarto said:

Isn't this a similar case as in this post

It is. I agree that the clever solution proposed by @JimmyJack is probably the simplest & most straightforward way to divide a single line into segments.

I was just trying to show that a relatively small change to the method @panjakrejn devised could be used to create any number of individual, diagonally aligned lines. In fact, as long as you can create a rectangle whose diagonal is the desired length of each line, you can use that to create the first diagonal line, after which you can duplicate it, align it to the end of the first one, & power duplicate as many more lines as you want. You can also come back later & use the same method to add more lines, even after deleting the rectangle(s).

All 3 1.10.8, & all 3 V2.5.6 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
A
ll 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

Hmmm 🤔. This does sound familiar 😝.

30 is starting to get up there. I wouldn't wan't to click 29 times on a line to get the # of nodes needed. And power dupe is equally as clicky.
So, in this case I'd do things a little differently.
(And, since the original question on how to divide an existing line expanded to include solutions of creating new objects....)

How about making a 60 sided polygon and just using half of it:

Link to comment
Share on other sites

  • 2 years later...

...two years later...

Quickest way: Open Rhino 3D:

  • Draw a line of the desired length
  • Use "divide by" , enter "30"
  • Export as SVG into Affinity Designer
On 8/31/2020 at 3:45 AM, panjakrejn said:

I have a diagonal straight line that I would like to divide into 30 equal line segments, any advice on the most straightforward way to accomplish this?

Edit: and fastest/easiest?

No, seriously: Just make a vertical line at the STARTING point of your line and make X+1 copies of it. Move the last element over, so it intersects with the END point of your line. Now just use the "Distribute horizontally" command on all the new vertical lines and your line is intersected by evenly spaced lines ...now just select them all and use DIVIDE... done!

Oh, wait... we are in Affinity Designer where this simple operation will NOT result in a divided line but in all the lines disappearing!!!

But not all is lost: just connect the first two intersecting points, creating a (diagonal) 1/X snippet of your line, CTRL+move it to effectively make an extension and then just keep hitting CTRL+J, each time adding another segment of the desired length until you reached the end of your original diagonal line, now consisting of X segments.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.