I know all the lengths of all the sides of a right angle triangle
I can calculate the angle I am looking for using my calculator - sin-1 (opposite over hypotenuse)
is there an function? in the FreeCAD spreadsheet that I can use to find the same answer? (i.e equivalent of the sin-1 button of my calculator)
Thanks in anticipation.
Finding an Angle via a spreadsheet formula [SOLVED]
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Finding an Angle via a spreadsheet formula [SOLVED]
Last edited by Laurie Hartley on Fri Aug 12, 2022 5:03 am, edited 1 time in total.
Re: Finding an Angle via a spreadsheet formula
Cheers,
Markus
Markus
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Re: Finding an Angle via a spreadsheet formula
Thanks Markus - I am away from my computer but will give it a go tomorrow and post on the outcome.mfro wrote: ↑Thu Aug 11, 2022 5:47 am Functions available for expressions: Expressions.
You want the asin() function.
- Shalmeneser
- Veteran
- Posts: 9558
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Finding an Angle via a spreadsheet formula
A sketch can give you the result visually.
- Attachments
-
- Capture d’écran 2022-08-11 211516.jpg (31.18 KiB) Viewed 567 times
Re: Finding an Angle via a spreadsheet formula
Hi
angle given 2 Vectors (paste in Python console)
type example (angle2(x1, y1, x2, y2, 1)):
mario
angle given 2 Vectors (paste in Python console)
Code: Select all
def angle2(vecteur_x1, vecteur_y1, vecteur_x2, vecteur_y2, modeTypeAngle):
# calculation of the slope of a line using two vectors
# If 'modeTypeAngle' = 1 then display in degrees else in radians
global uniteAs
try:
deltaX = vecteur_x2 - vecteur_x1
deltaY = vecteur_y2 - vecteur_y1
if modeTypeAngle == 1:
angle = degrees(atan2(float(deltaY),float(deltaX))) # degrees
uniteAs = " deg"
else:
angle = atan2(float(deltaY),float(deltaX)) # radian
uniteAs = " rad"
#return round(angle,6)
return angle
except Exception:
return 0
Code: Select all
angle2(13.475, -3.9282,-11.1332, 6.6107, 1) # modeTypeAngle 1=degrees / 0=radians
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
-
- Posts: 526
- Joined: Mon Feb 27, 2017 5:33 am
- Location: Australia
Re: Finding an Angle via a spreadsheet formula
@Shalmeneser &@mario52 - thank you for those tips.
I was aware of the sketcher option Shalmaneser.
Mario, coding is a bit beyond my capabilities just now but I will experiment with your code to see if I can learn something new.
As it is though the solution proposed by @mfro (Markus) using the asin() expression is perfect for me - thank you Markus.
Thanks again to all
I was aware of the sketcher option Shalmaneser.
Mario, coding is a bit beyond my capabilities just now but I will experiment with your code to see if I can learn something new.
As it is though the solution proposed by @mfro (Markus) using the asin() expression is perfect for me - thank you Markus.
Thanks again to all