Andrew1979 Posted December 20, 2015 Posted December 20, 2015 I have searched the forum and tried to figure this out. How do i work out TAN? Why doesn't AutoLISP even not have this available? I have tried reading various posts on it but can't make any sense of any of it and was surprised to not find one thread on it in the search on this forum All I want to do is work out the opposite side of a triangle. I have the adjacent length and the angle but with all these radians and degrees and other crap I just can't get it to work. When I use a calculator I solve it in a second. But not with AutoLISP. In the image above, I know the angle 25 degrees and the adjacent which is 600mm (not shown) I need to work out the opposite (shown as 279.78mm) I have tried: (/ (sin 25)(cos 25)) But that works out different than the calculator. I think because of radians. So I convert the radians to degrees and still get the wrong answer. I think LISP should stand for "Lost is Stupid Pythagorean (Theory)" Please help. Quote
eldon Posted December 20, 2015 Posted December 20, 2015 I tried to Google your problem, and the first one was this site. I am sure there are many more sources of information. P.S. if you are using whole angles, the hypotenuse length is 662.03 Quote
Andrew1979 Posted December 20, 2015 Author Posted December 20, 2015 thanks, yeah i saw that. Just can't get any of the code to work the way i want it to. I know the info is there, I just don't understand why my code doesn't work Quote
rlx Posted December 20, 2015 Posted December 20, 2015 See this one : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/sin-cos-tan/td-p/868027 (btw radians instead of degrees) gr. Rlx Quote
Lee Mac Posted December 20, 2015 Posted December 20, 2015 Using my Trigonometric Functions: _$ (* 600.0 (tan (* pi (/ 25.0 180.0)))) 279.785 Quote
Andrew1979 Posted December 20, 2015 Author Posted December 20, 2015 Ok, I think I have it sorted out. I don't understand why this works exactly or even understand the formula but this is how to work out the opposite side of a right angled triangle when you know the adjacent side and angle [color=red]([/color][color=royalblue]setq[/color] AngInDegrees[color=seagreen] 25[/color][color=red])[/color][color=gray]; In this example, I set the angle to 25 degrees (not radians)[/color] [color=red]([/color][color=royalblue]setq[/color] SIDE [color=seagreen]600[/color][color=red])[/color][color=gray]; In this example I set the opposite side to 600mm)[/color] [color=red]([/color][color=royalblue]setq[/color] AngInDegrees-90 [color=red]([/color][color=royalblue]-[/color] AngInDegrees [color=seagreen]90[/color][color=red]))[/color][color=gray];I then minus 90 from the the 25 [/color] [color=red]([/color][color=royalblue]setq[/color] c [color=red]([/color][color=royalblue]/[/color] SIDE [color=red]([/color][color=royalblue]sin[/color] [color=red]([/color][color=royalblue]*[/color] AngInDegrees-90 [color=red]([/color][color=royalblue]/ pi [/color][color=seagreen]180[/color][color=red])))))[/color][color=gray];Do some formula[/color] [color=red]([/color][color=royalblue]setq[/color] b [color=red]([/color][color=royalblue]sqrt [/color][color=red]([/color][color=royalblue]-[/color] [color=red]([/color][color=royalblue]*[/color] c c[color=red])[/color] [color=red]([/color][color=royalblue]*[/color] SIDE SIDE[color=red]))))[/color][color=gray];Do some formula[/color] What you end up with is a triangle where the opposite side equals 279.78mm. The value of SETQ b = 279.78mm So it works and if you need to work out this type of triangle this formula will work. Just replace the variable names to suit your own needs. I wrote all that out so if someone searches for it i the future it may be helpful....and someone might even find it from a google search Quote
Andrew1979 Posted December 20, 2015 Author Posted December 20, 2015 thanks Lee, you posted as I was writing my last response. i will have to look at that. Than ks everyone. Quote
Lee Mac Posted December 20, 2015 Posted December 20, 2015 I don't understand why this works exactly or even understand the formula but this is how to work out the opposite side of a right angled triangle when you know the adjacent side and angle [color=red]([/color][color=royalblue]setq[/color] AngInDegrees[color=seagreen] 25[/color][color=red])[/color][color=gray]; In this example, I set the angle to 25 degrees (not radians)[/color] [color=red]([/color][color=royalblue]setq[/color] SIDE [color=seagreen]600[/color][color=red])[/color][color=gray]; In this example I set the opposite side to 600mm)[/color] [color=red]([/color][color=royalblue]setq[/color] AngInDegrees-90 [color=red]([/color][color=royalblue]-[/color] AngInDegrees [color=seagreen]90[/color][color=red]))[/color][color=gray];I then minus 90 from the the 25 [/color] [color=red]([/color][color=royalblue]setq[/color] c [color=red]([/color][color=royalblue]/[/color] SIDE [color=red]([/color][color=royalblue]sin[/color] [color=red]([/color][color=royalblue]*[/color] AngInDegrees-90 [color=red]([/color][color=royalblue]/ pi [/color][color=seagreen]180[/color][color=red])))))[/color][color=gray];Do some formula[/color] [color=red]([/color][color=royalblue]setq[/color] b [color=red]([/color][color=royalblue]sqrt [/color][color=red]([/color][color=royalblue]-[/color] [color=red]([/color][color=royalblue]*[/color] c c[color=red])[/color] [color=red]([/color][color=royalblue]*[/color] SIDE SIDE[color=red]))))[/color][color=gray];Do some formula[/color] Your code is essentially calculating the length of the hypotenuse using the known adjacent side & angle, and then using Pythagoras' Theorem to calculate the remaining unknown side length. You can omit the subtraction of 90 degrees by simply replacing sin with cos. Quote
Recommended Posts
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.