Author Topic: Coordinates in the triangle  (Read 7048 times)

0 Members and 1 Guest are viewing this topic.

velasquez

  • Newt
  • Posts: 195
Coordinates in the triangle
« on: October 16, 2018, 08:02:56 AM »
I have problem to calculate the coordinates of the point "xpto" in the triangle.
Can someone help me?

Tanks.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Coordinates in the triangle
« Reply #1 on: October 16, 2018, 08:15:18 AM »
"Cheating" with trans:
Code - Auto/Visual Lisp: [Select]
  1. (defun tpt ( p1 p2 p3 / v )
  2.     (setq v (mapcar '- p3 p1))
  3.     (trans (cons (car (trans p2 0 v)) (cdr (trans p1 0 v))) v 0)
  4. )
  5.  

Assumes points are in WCS; compatible with UCS planes parallel to WCS plane only.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Coordinates in the triangle
« Reply #2 on: October 16, 2018, 08:30:21 AM »
"Cheating" with trans:
Code - Auto/Visual Lisp: [Select]
  1. (defun tpt ( p1 p2 p3 / v )
  2.     (setq v (mapcar '- p3 p1))
  3.     (trans (cons (car (trans p2 0 v)) (cdr (trans p1 0 v))) v 0)
  4. )
  5.  

Assumes points are in WCS; compatible with UCS planes parallel to WCS plane only.
:)  Grande.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Coordinates in the triangle
« Reply #3 on: October 16, 2018, 08:48:52 AM »
Another convoluted though and untested...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / v^v projp2pp xpto p1 p2 p3 pt )
  2.  
  3.   (defun v^v ( u v )
  4.     (list
  5.       (- (* (cadr u) (caddr v)) (* (caddr u) (cadr v)))
  6.       (- (* (caddr u) (car v)) (* (car u) (caddr v)))
  7.       (- (* (car u) (cadr v)) (* (cadr u) (car v)))
  8.     )
  9.   )
  10.  
  11.   (defun projp2pp ( p p1 p2 / v nv n )
  12.     (setq v (mapcar '- p2 p1))
  13.     (setq nv (v^v (mapcar '- p p1) (mapcar '- p p2)))
  14.     (setq n (v^v v nv))
  15.     (inters p (mapcar '+ p n) p1 p2 nil)
  16.   )
  17.  
  18.   (defun xpto ( p1 p2 p3 / pp )
  19.     (setq pp (projp2pp p2 p1 p3))
  20.     (mapcar '+ p1 (mapcar '- p2 pp))
  21.   )
  22.  
  23.   (initget 1)
  24.   (setq p1 (trans (getpoint "\nP1 : ") 1 0))
  25.   (initget 1)
  26.   (setq p2 (trans (getpoint "\nP2 : ") 1 0))
  27.   (initget 1)
  28.   (setq p3 (trans (getpoint "\nP3 : ") 1 0))
  29.   (setq pt (xpto p1 p2 p3))
  30.   (entmake (list '(0 . "POINT") (cons 10 pt)))
  31.   (princ)
  32. )
  33.  
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Coordinates in the triangle
« Reply #4 on: October 16, 2018, 09:26:12 AM »
Interesting stuff, no doubt. But I don't understand. I see a green and a yellow line that are not parallel to any of the magenta lines.

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #5 on: October 16, 2018, 10:08:24 AM »
Interesting stuff, no doubt. But I don't understand. I see a green and a yellow line that are not parallel to any of the magenta lines.

Hello Roy

The yellow line and a green line are to show the location of the coordinates that I need to find. The angle between these lines is always 90 degrees.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Coordinates in the triangle
« Reply #6 on: October 16, 2018, 10:35:00 AM »
Interesting stuff, no doubt. But I don't understand. I see a green and a yellow line that are not parallel to any of the magenta lines.

Hello Roy

The yellow line and a green line are to show the location of the coordinates that I need to find. The angle between these lines is always 90 degrees.
I guessed as much. But the other contributors have made the assumption that the green line is parallel to a magenta line. Conclusion: your image is quite confusing.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Coordinates in the triangle
« Reply #7 on: October 16, 2018, 12:25:49 PM »
"Cheating" with trans:
Code - Auto/Visual Lisp: [Select]
  1. (defun tpt ( p1 p2 p3 / v )
  2.     (setq v (mapcar '- p3 p1))
  3.     (trans (cons (car (trans p2 0 v)) (cdr (trans p1 0 v))) v 0)
  4. )
  5.  

Assumes points are in WCS; compatible with UCS planes parallel to WCS plane only.

Nicely done Lee, direct and concise...
This one works for any 3d points
Code - Auto/Visual Lisp: [Select]
  1.     (setq v (mapcar '- p3 p1)
  2.           p1 (trans p1 0 v)
  3.           p2 (trans p2 0 v)
  4.     )
  5.     (trans (list (car p2) (cadr p2) (caddr p1)) v 0)

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #8 on: October 16, 2018, 01:28:16 PM »
I'm sorry if the picture was confusing.
The functions always return the coordinate of p2, I need to find out the coordinate of the xpto point.
Remembering that I always have p1 p2 and p3. I posted a drawing showing some triangle situations.

Tanks.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Coordinates in the triangle
« Reply #9 on: October 16, 2018, 01:41:36 PM »
So...
Cyan line is not parallel to p1p3 line?
Then how do you get cyan?
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

kirby

  • Newt
  • Posts: 132
Re: Coordinates in the triangle
« Reply #10 on: October 16, 2018, 02:01:05 PM »
There are an infinite number of rays from P1 and P2 that are perpendicular to each other.  You need to add another constraint (eg. ray from P1 is parallel to X axis, etc.)

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #11 on: October 16, 2018, 02:53:55 PM »
The point you need to calculate is always the projection from point p1 to the projection of point p2 at an angle of 90 degrees.
« Last Edit: October 16, 2018, 03:00:00 PM by velasquez »

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Coordinates in the triangle
« Reply #12 on: October 16, 2018, 03:10:50 PM »
Men, like Kirby explained, there are infinite number of possibilities of such projections - you don't say at which orientation is either cyan or perpendicular projection... Just create half circle from p1 to p2... All points on that half circle could be xpto point + half circle can rotate in 3d around p1 p2 axis which makes it sphere of infinite xpto points on its surface...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #13 on: October 16, 2018, 03:25:57 PM »
Men, like Kirby explained, there are infinite number of possibilities of such projections - you don't say at which orientation is either cyan or perpendicular projection... Just create half circle from p1 to p2... All points on that half circle could be xpto point + half circle can rotate in 3d around p1 p2 axis which makes it sphere of infinite xpto points on its surface...


Hello Ribarm,

Please note the drawing I posted, what I need is to learn to calculate the coordinate of the point described as xpto, in relation to the x and y axes.
Using the id command at the end of the green line will show this.

I'm sorry but I can not show it better.

Thanks

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Coordinates in the triangle
« Reply #14 on: October 16, 2018, 05:19:51 PM »
Nicely done Lee, direct and concise...
This one works for any 3d points

Thanks Stefan, in hindsight that makes more sense.  :wink:

Interesting stuff, no doubt. But I don't understand. I see a green and a yellow line that are not parallel to any of the magenta lines.
The yellow line and a green line are to show the location of the coordinates that I need to find. The angle between these lines is always 90 degrees.

I assumed that P3-P1 was parallel to P2-XPTO; without this assumption, any point on the circle with diameter P1-P2 meets your criteria -



Hence there would be infinite solutions, as kirby correctly notes.

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #15 on: October 16, 2018, 06:15:51 PM »
Nicely done Lee, direct and concise...
This one works for any 3d points

Thanks Stefan, in hindsight that makes more sense.  :wink:

Interesting stuff, no doubt. But I don't understand. I see a green and a yellow line that are not parallel to any of the magenta lines.
The yellow line and a green line are to show the location of the coordinates that I need to find. The angle between these lines is always 90 degrees.

I assumed that P3-P1 was parallel to P2-XPTO; without this assumption, any point on the circle with diameter P1-P2 meets your criteria -



Hence there would be infinite solutions, as kirby correctly notes.

Hello lee
Is there a way to find just the point at the intersection of the lines that I marked in your image?


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Coordinates in the triangle
« Reply #16 on: October 16, 2018, 06:31:44 PM »
Hello lee
Is there a way to find just the point at the intersection of the lines that I marked in your image?

Assuming the orange horizontal line is parallel to the base of the triangle, this is what my code (and Stefan's code) will give you.

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #17 on: October 17, 2018, 08:48:38 AM »
Hello lee
Is there a way to find just the point at the intersection of the lines that I marked in your image?
Assuming the orange horizontal line is parallel to the base of the triangle, this is what my code (and Stefan's code) will give you.

Hello Lee
Assuming the base of the triangle is not parallel to the orange horizontal line how can I compute the xpto point?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Coordinates in the triangle
« Reply #18 on: October 17, 2018, 09:17:13 AM »
(setq xpto (list (car p1) (cadr p2)))
(princ xpto)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Coordinates in the triangle
« Reply #19 on: October 17, 2018, 09:38:25 AM »
(setq xpto (list (car p1) (cadr p2)))
(princ xpto)
I thought the same thing too but from the other examples it won't work.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Coordinates in the triangle
« Reply #20 on: October 17, 2018, 12:42:13 PM »
Is there a way to find just the point at the intersection of the lines that I marked in your image?
Assuming the orange horizontal line is parallel to the base of the triangle, this is what my code (and Stefan's code) will give you.
Assuming the base of the triangle is not parallel to the orange horizontal line how can I compute the xpto point?

Then the problem requires additional constraints - please refer to my earlier post.

velasquez

  • Newt
  • Posts: 195
Re: Coordinates in the triangle
« Reply #21 on: October 17, 2018, 04:37:54 PM »
Thank you to everyone who helped me.