Jump to content

Trigonometric Exercise 1


samifox

Recommended Posts

Hi

I start learning trigo,

My program should do a simple thing,

  1. User press p1, than p2 (vertically up to down)
  2. A line will be drawn , composing segment a
  3. User press p3(horizontally, forming the base)
  4. segment c (hyp) distance and angle will take place
  5. A line will be drawn composing segment c

 

Final output is not correct

Any idea why?

 

 

(defun finding-c(/ p1 p2 p3 dst segC isegC)
 (setq p1 (getpoint "\nSpecify first point"))
 (setq p2 (getpoint p1 "\nSpecify second point"))
 (command "_pline" p1 p2 "")
 
 (setq p3 (getpoint p2 "\nSpecify third point"))
 (command "_pline" p2 p3 "")


;;; get the length of the missing segment
 (setq dst (sqrt
      (+
	(* (distance  p1 p2) (distance  p1 p2)) ;power 2
	(* (distance  p2 p3) (distance  p2 p3)) ;power 2
      )
    )
)

 

 ;;; get the angle of the missing segment

 (setq raw (/ (distance  p2 p3) (distance  p1 p2)));;; get tanges
 

(setq p4 (polar p3 (atan raw)  dst))
 (command "_pline" p3 p4 "")
 
 
 )

Link to comment
Share on other sites

Final output is not correct

Any idea why?

 

The angle that you are calculating is interior angle of the triangle, whereas the angle supplied to the polar function is measured from the x-axis.

Link to comment
Share on other sites

Samifox Why not just draw 1 pline ? rather than 3 or do you want all 3 ? You can still do angles etc

 

(setq p1 (getpoint "\nSpecify first point"))
 (setq p2 (getpoint p1 "\nSpecify second point"))
 (setq p3 (getpoint p2 "\nSpecify third point"))
 (command "_pline" P1 p2 p3 "C" )

Edited by SLW210
Link to comment
Share on other sites

hi

 

as far as i understand ,

 

(polar (start in p3) (orient 27 degrees) (shoot 11.18 length))

 

isnt that right?

 

(see attachment)

trigo1.jpg

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...