khoshravan Posted August 14, 2011 Posted August 14, 2011 I have to locate orthocenter and centeriod of many triangles. What I now do is, draw the orthogonals separately and find their intersection (although having two of then is enough) and in some cases I have to extend the sides of triangle for obtuse one. This is time consuming. In the attached file, from quadrilateral A1A2A3A4 I want to produce the other one H1H2H3H4 Could anybody help me to automate this procedure? PS Orthocenter: intersection point of 3 orthogonal lines of a triangle centeriod: intersection point of 3 medians of a triangle 1.dwg Quote
eldon Posted August 14, 2011 Posted August 14, 2011 I am not quite sure whether you are using Osnaps to draw your figures. If I zoom into corner A2, there are lines not quite meeting. You do not need to extend the lines of an obtuse angle, as the Osnap perpendicular will find the extended line automatically. Are the points A1, A2, A3 and A4 all on the circle? I drew a similar A polygon, then constructed the Orthocentre H3. Drew a line from H3 to A2. Copied and rotated 180° the A polygon about the middle point of this line. Job done. Quote
khoshravan Posted August 14, 2011 Author Posted August 14, 2011 I am not quite sure whether you are using Osnaps to draw your figures. If I zoom into corner A2, there are lines not quite meeting. I selected the points on circle by point command, that's why they are not meeting completely. I figure our this problem after posting. You do not need to extend the lines of an obtuse angle, as the Osnap perpendicular will find the extended line automatically. If Osnap perpendicular works for extension, that's great. I will check. Are the points A1, A2, A3 and A4 all on the circle? Yes all points are on the circle. I drew a similar A polygon, then constructed the Orthocentre H3. Drew a line from H3 to A2. Copied and rotated 180° the A polygon about the middle point of this line. Job done. After constructing the drawing, I figured out that it is the rotation of original quadrilateral but couldn't find the base point for rotation. Please tell me how do you find this rotation base point? Were you familiar with this sort of problems or just the drawing directed you to above conclusions on construction of the drawing without drawing all orthocenters? I am trying to prove what you concluded. Off course drawing precisely with aid of ACAD could help and give hint for you, but finally it should be proved. Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 Here is a LISP function to calculate the Orthocenter of three points: ;; Orthocenter - Lee Mac ;; Args: p1,p2,p3 - WCS points (defun LM:Orthocenter ( p1 p2 p3 ) (setq v1 (mapcar '- p2 p1) v2 (mapcar '- p3 p1) nm (v^v v1 v2) ) (inters p3 (mapcar '+ p3 (v^v v1 nm)) p2 (mapcar '+ p2 (v^v v2 nm)) nil ) ) ;; Vector Cross Product - Lee Mac ;; Args: u,v - vectors in R^3 (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) Here is a function to test it, it will create a point at the orthocenter: (defun c:test ( / p1 p2 p3 ) (if (and (setq p1 (getpoint "\nFirst Point: ")) (setq p2 (getpoint "\nSecond Point: ")) (setq p3 (getpoint "\nThird Point: ")) ) (entmake (list (cons 0 "POINT") (cons 10 (apply 'LM:Orthocenter (mapcar '(lambda ( p ) (trans p 1 0)) (list p1 p2 p3)) ) ) ) ) ) (princ) ) ;; Orthocenter - Lee Mac ;; Args: p1,p2,p3 - WCS points (defun LM:Orthocenter ( p1 p2 p3 ) (setq v1 (mapcar '- p2 p1) v2 (mapcar '- p3 p1) nm (v^v v1 v2) ) (inters p3 (mapcar '+ p3 (v^v v1 nm)) p2 (mapcar '+ p2 (v^v v2 nm)) nil ) ) ;; Vector Cross Product - Lee Mac ;; Args: u,v - vectors in R^3 (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) Call it with 'test'. Lee Quote
khoshravan Posted August 14, 2011 Author Posted August 14, 2011 Dear Lee Hi. Actually I was hoping that you read this thread and reply to it as you are the man for LISP and automation. Let me check and reach you again. Thanks hundred times. BR Khoshravan Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 Thanks Khoshravan, I feel flattered that my reputation precedes me Let me know how you get on Quote
eldon Posted August 14, 2011 Posted August 14, 2011 After constructing the drawing, I figured out that it is the rotation of original quadrilateral but couldn't find the base point for rotation. Please tell me how do you find this rotation base point? I guessed at the base point of rotation by looking at your figure. Quite often if something looks right, you can guess at it without proof. Were you familiar with this sort of problems or just the drawing directed you to above conclusions on construction of the drawing without drawing all orthocenters? I am trying to prove what you concluded. Of course drawing precisely with aid of ACAD could help and give hint for you, but finally it should be proved. I have always had an interest with geometrical problems, which is made easier when one can draw precisely with Osnaps. Quote
khoshravan Posted August 14, 2011 Author Posted August 14, 2011 Dear Lee I checked the codes you presented. The 2nd one "A function to test" worked fine as I wanted. Thanks so much for your knowledge and generosity. But for the first one, I loaded it same was as the 2nd one and CAD says: Command: APPLOAD Orthocenter.lsp successfully loaded. However it failed to invoke the command. Command: orthocenter I know only basics on LISP and I think I am doing something wrong. Actually I don't understand the difference between two of them. As far as my question, the 2nd codes satisfies me completely8) and I don't what the first code do? Unknown command "ORTHOCENTER". Press F1 for help. Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 The second code is a command defined as 'c:test' which calls the subfunctions defined in the first code. The first code has three subfunctions - notice there are no 'defun c:' statements. The first: 'LM:Orthocenter' requires three arguments, namely: p1, p2, p3; these points are supplied when it is called within the second code. Just as you would supply numerical arguments to the '+' function: (+ arg1 arg2 arg3 ... argN), you supply three point arguments to my subfunction: (LM:Orthocenter point1 point2 point3). So, if you wanted to write your own application, you could call my Orthocenter function in the following way: (defun c:MyCommand ( / pt1 pt2 pt3 ) (if (and (setq pt1 (getpoint "\nFirst Point: ")) (setq pt2 (getpoint "\nSecond Point: ")) (setq pt3 (getpoint "\nThird Point: ")) ) (LM:Orthocenter pt1 pt2 pt3) ) (princ) ) Quote
khoshravan Posted August 14, 2011 Author Posted August 14, 2011 Thanks for your prompt reply. Do you mean I have nothing to do with the first code? Quote
Lee Mac Posted August 14, 2011 Posted August 14, 2011 Edited my last response above ^^ Do you mean I have nothing to do with the first code? That is entirely up to you. If you wanted to define your own command in which you needed to calculate the Orthocenter of three points, then you could call my function defined in the first code, (as demonstrated by the example program in the second code). Notice also how the 'LM:Orthocenter' function calls the other subfunction: 'v^v' to calculate the Vector Cross product of two vectors. 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.