Finding an Angle via a spreadsheet formula [SOLVED]

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
Laurie Hartley
Posts: 522
Joined: Mon Feb 27, 2017 5:33 am
Location: Australia

Finding an Angle via a spreadsheet formula [SOLVED]

Post by Laurie Hartley »

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.
Last edited by Laurie Hartley on Fri Aug 12, 2022 5:03 am, edited 1 time in total.
User avatar
mfro
Posts: 662
Joined: Sat Sep 23, 2017 8:15 am

Re: Finding an Angle via a spreadsheet formula

Post by mfro »

Functions available for expressions: Expressions.

You want the asin() function.
Cheers,
Markus
Laurie Hartley
Posts: 522
Joined: Mon Feb 27, 2017 5:33 am
Location: Australia

Re: Finding an Angle via a spreadsheet formula

Post by Laurie Hartley »

mfro wrote: Thu Aug 11, 2022 5:47 am Functions available for expressions: Expressions.

You want the asin() function.
Thanks Markus - I am away from my computer but will give it a go tomorrow and post on the outcome.
User avatar
Shalmeneser
Veteran
Posts: 9474
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: Finding an Angle via a spreadsheet formula

Post by Shalmeneser »

A sketch can give you the result visually.
Attachments
Capture d’écran 2022-08-11 211516.jpg
Capture d’écran 2022-08-11 211516.jpg (31.18 KiB) Viewed 517 times
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: Finding an Angle via a spreadsheet formula

Post by mario52 »

Hi

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

type example (angle2(x1, y1, x2, y2, 1)):

Code: Select all

angle2(13.475, -3.9282,-11.1332, 6.6107,  1)  # modeTypeAngle 1=degrees / 0=radians 
mario
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.
Laurie Hartley
Posts: 522
Joined: Mon Feb 27, 2017 5:33 am
Location: Australia

Re: Finding an Angle via a spreadsheet formula

Post by Laurie Hartley »

@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
Post Reply