Making ellipse or rectangle always half as wide as its width

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
Frotz
Posts: 105
Joined: Thu Jun 21, 2018 1:52 am

Making ellipse or rectangle always half as wide as its width

Post by Frotz »

How is the formula editor for constraints supposed to work? I have an ellipse that I want to ensure is always half as wide as its length (or do some arithmetical transform to set Width as N x Height). Where is it documented how to make sense of the <<ThingName>> stuff that pops up in the formula editor when you click on the formula icon when editing a constraint? I figured it would be something like <<ThingName>>.Length (this grammar doesn't work) to stand in for a particular value on some other constraint.

Code: Select all

OS: Debian GNU/Linux 12 (bookworm) (MATE/mate)
Word size of FreeCAD: 64-bit
Version: 0.21.0.33341 (Git)
Build type: Release
Branch: master
Hash: 8a3c8258dfe92bdfe5efcfea43b0c1e2a224543c
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * Pyramids-and-Polyhedrons
  * sheetmetal 0.2.63
  * freecad.gears 1.0.0
  * A2plus 0.4.60k
  * fasteners 0.4.56
  * Manipulator 1.5.0
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Making ellipse or rectangle always half as wide as its width

Post by edwilliams16 »

Expressions

The downside of trying to use self referential expression within a sketch is that it is outside the sketcher solver. It might not ever converge.

Absent a ratio feature, you can construct any desired ratio with a right angle construction triangle. Set your desired lengths equal to two sides of the triangle. Make the lengths of the two sides in the desired ratio - but as reference lengths. Set the angle of the triangle as a driving constraint, fixing its geometry.
Screenshot 2023-06-03 at 1.59.04 PM.png
Screenshot 2023-06-03 at 1.59.04 PM.png (41.18 KiB) Viewed 811 times
viewtopic.php?t=69147

EDIT Rectangles are much simpler.
Screenshot 2023-06-03 at 3.00.19 PM.png
Screenshot 2023-06-03 at 3.00.19 PM.png (20.96 KiB) Viewed 780 times
Attachments
twotooneellipse.FCStd
(4.14 KiB) Downloaded 6 times
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: Making ellipse or rectangle always half as wide as its width

Post by chrisb »

If it is really and always double you don't need any dimensions. Use three lines of equal length, one vertical, two horizontal:
Attachments
SnipScreenshot-2300a9.png
SnipScreenshot-2300a9.png (4.05 KiB) Viewed 754 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Workshop_Notes
Posts: 590
Joined: Wed Sep 29, 2021 8:35 am

Re: Making ellipse or rectangle always half as wide as its width

Post by Workshop_Notes »

chrisb wrote: Sun Jun 04, 2023 5:16 am If it is really and always double you don't need any dimensions.
Clever and understated.

That method has much wider applicability in that it can be used for _any_ rational (able to be expressed as a fraction) number.

Even for irrational numbers, continued fractions can be used to obtain a rational number arbitrarily close to the correct one (e.g pi can can be 355/113). [side note, what is the angle of Ed's right angle triangle for pi ratio sides?]

It would become slightly tedious when the numerator and denominator of the rational number sum to more than about 7 though. I wonder if Lattice 2 might be a good way of producing the ratio (make a 355 x 113 array).
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Making ellipse or rectangle always half as wide as its width

Post by edwilliams16 »

Workshop_Notes wrote: Sun Jun 04, 2023 8:03 am
Even for irrational numbers, continued fractions can be used to obtain a rational number arbitrarily close to the correct one (e.g pi can can be 355/113). [side note, what is the angle of Ed's right angle triangle for pi ratio sides?]

It would become slightly tedious when the numerator and denominator of the rational number sum to more than about 7 though. I wonder if Lattice 2 might be a good way of producing the ratio (make a 355 x 113 array).
Tedious yes - when all you need to do is make a triangle with one side 1 and the other pi and make the angle a driving constraint - plus it's good to machine accuracy.
The angle is atan (pi) (or atan(1/pi) ) depending which side is which. But you don't need trig - the correct angle is constructed.
Post Reply