Set lenght of a line

Post questions on how to use or achieve an effect in Inkscape.
toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Set lenght of a line

Postby toxigames » Mon Oct 24, 2016 10:08 pm

Is it possible to set the length of a line directly by inputting a numerical value?

The reason why I want to do this it's because I am playing around with predictive aiming methods for a game. For example I have a gun that aims at a target. The distance to this target divided by the speed of the guns bullet is the time it takes for the bullet to hit the target, if the target don't move. However the target does move, so it has direction and speed. So in the time it would take the guns bullet to reach the targets initial position the target would have moved to a new position: The targets vector (the line) would have grown to a new length: lengthOfLine = targetSpeed * timeForBulletToReachTargetsInitialPosition. And the end point of this line would then be the position to point the gun at for the bullet to hit the target. All this is just because I want to visualize what happens and I think Inkscape would be a perfect program to do this in. It would just be so much easier to then be able to directly set the length of the line with the result of this simple calculation, than each time having to solve pythagoraes to know where to place the end point of the line (which would be the alternative way of making the line the length I want).

I am thinking if there was an extension where you input desired length and then it would automatically solve pythagoraes for you and set the lines end point X/Y = line end point X/Y + vector component X/Y.

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Set lenght of a line

Postby prkos » Tue Oct 25, 2016 1:13 am

I'm not sure I understand exactly what you need, but there is an extension that draws Parametric Curves. You enter the formulae and some parameters and apply it to a rectangle.

You can find it under Extensions > Render > Parametric Curves...
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: Set lenght of a line

Postby toxigames » Tue Oct 25, 2016 1:16 am

prkos, I just need to set the length of a line :)

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Set lenght of a line

Postby prkos » Tue Oct 25, 2016 1:20 am

Does that mean you need help with drawing the line, or with calculating how long it should be?

To draw precise lengths use grids and snapping. Maybe there is some geometry trick to help with calculating if that's the part you need help with.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: Set lenght of a line

Postby toxigames » Tue Oct 25, 2016 1:31 am

I just need to directly set the length of the line. Say I want it to be 2.657 I want to be able to tell Inkscape: "hey inkscape, make this line 2.657" and it will do it, no questions asked. :D (maybe it's not possible, cause I couldn't find any features to do this, but maybe I didn't look the right places?)

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Set lenght of a line

Postby prkos » Tue Oct 25, 2016 1:52 am

Objects in SVG have width and height, and there is a nice toolbar option that lets you enter the value directly.

If we're talking about lines specifically you can create a completely horizontal line (Pen tool and hold Ctrl). Then with Selector tool active enter the number into the W field. This will automatically scale the object.

But since line has stroke properties which can behave differently when scaled (to make the stroke change with the scale or not), it might be more convenient to use a thin rectangle instead of a line. Use the Rectangle tool (F4) to create a wide rectangle, and enter the with value into W field, with the Rectangle tool active.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

Moini
Posts: 3291
Joined: Mon Oct 05, 2015 10:44 am

Re: Set lenght of a line

Postby Moini » Tue Oct 25, 2016 1:59 am

Additional: Whether the path length matches the visible line length depends upon the end caps you've selected in the stroke properties tab of the fill and stroke dialog - if you select the first (leftmost) option, the nodes will be exactly at the ends of the visible horizontal line, and you can use the scaling input field or snapping, without needing to resort to rectangles.
Last edited by Moini on Tue Oct 25, 2016 2:36 am, edited 1 time in total.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

tylerdurden
Posts: 2322
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: Set lenght of a line

Postby tylerdurden » Tue Oct 25, 2016 2:16 am

In CAD the operation is sometimes called "real time dimensioning", but in CAD the line also becomes fixed length, which Inkscape doesn't do either.

If the target always originates from the same point, You could use a circle centered on the target origin as a reference, and snap the line terminus to circle. Use object transform on the circle to scale and retain the center, for each time you need to constrain a line to a distance. (tip: circle will be valued as a diameter, not radius, but you enter the transform value as "n*2" to make the circle the radius that matches the desired line length).

Without a more detailed description of the workflow, it will be hard to suggest better possible solutions.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

Lazur
Posts: 4705
Joined: Tue Jun 14, 2016 10:38 am

Re: Set lenght of a line

Postby Lazur » Tue Oct 25, 2016 3:00 am

When "real lengths" are needed regardless the angle the only thing I can think of is using rectangles.
Their width/height can be specified independently to their transformation or bounding box.

tylerdurden
Posts: 2322
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: Set lenght of a line

Postby tylerdurden » Tue Oct 25, 2016 3:17 am

^^ That's a good point. I'm usually working without fill or stroke (in outline mode), so I forget that.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Set lenght of a line

Postby theozh » Tue Feb 28, 2017 7:50 am

I stumbled across the same problem...
Really? One has to draw a rectangle or a circle if you just need a straight line of a defined length starting from a certain node with a certain angle? Are you serious? Argh... :shock: No better solution?
Win7/64, Inkscape 0.92.2

User avatar
brynn
Posts: 10308
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Set lenght of a line

Postby brynn » Tue Feb 28, 2017 7:55 am

No, you can draw a simple path of the length you want. You want a box to type in a number, use the Width or Height on Selection control bar. When the line is the length you want, rotate it to a specific angle, using Object menu > Transform.

Lazur
Posts: 4705
Joined: Tue Jun 14, 2016 10:38 am

Re: Set lenght of a line

Postby Lazur » Tue Feb 28, 2017 7:58 am

At least that's how I would do it with the recent toolset and my knowledge.
Off topic:
Haven't really checked all the new features, probably an extension or a path effect is the most one can expect...
Oh the rotate canvas feature that is being developed right now may solve it as well?
I know in archicad you can draw polylines by clicking, adjusting the cursor to a certain direction and typing in a value etc. but that's a "different story".

msdobrescu
Posts: 59
Joined: Tue Aug 02, 2011 6:50 am

Re: Set lenght of a line

Postby msdobrescu » Sat Apr 20, 2019 7:20 pm

Yes, it works by inputting the numeric value in a box, for lines, but how to decide in which direction, from which point to extend or shrink, maybe taking into consideration the middle of the line too...

User avatar
druban
Posts: 1849
Joined: Fri Nov 20, 2009 10:48 pm

Re: Set lenght of a line

Postby druban » Sun Apr 21, 2019 10:07 am

These answers have been given above already, and also you should notice that the question was asked (and answered) several years ago!

In any case the status bar at the bottom of the window tells you exactly how long and at what angle the line you are drawing is, which may not have been available when the original question was asked. That's one of the problems with resurrecting old threads: the software may have been updated to the point that the original question is no longer relevant.
Your mind is what you think it is.

msdobrescu
Posts: 59
Joined: Tue Aug 02, 2011 6:50 am

Re: Set lenght of a line

Postby msdobrescu » Sun Apr 21, 2019 3:39 pm

Indeed, shoot me for that !:)
Sorry to be unclear, I was not asking to know where the line/path/shape extends, but how to make it extend in a certain direction by setting the value in those boxes.


Return to “Help with using Inkscape”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 14 guests