Author Topic: get center and radius of sphere by picking 3points  (Read 926 times)

0 Members and 1 Guest are viewing this topic.

motee-z

  • Newt
  • Posts: 40
get center and radius of sphere by picking 3points
« on: March 10, 2023, 12:16:12 PM »
Hello friends
any help for a lisp to get center and radius of sphere by picking 3d  3 points
thanks

ribarm

  • Gator
  • Posts: 3257
  • Marko Ribar, architect
Re: get center and radius of sphere by picking 3points
« Reply #1 on: March 10, 2023, 01:33:11 PM »
You meant 4 points - not coplanar?
3 points are needed for creating circle - do you need sphere with circle as equatorial parallel...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #2 on: March 10, 2023, 02:52:16 PM »
In autocad we use 3point in space not in the same level
But i know in mathemtic in we need four point in space to creat sphere so i dont know which is true

57gmc

  • Bull Frog
  • Posts: 365
Re: get center and radius of sphere by picking 3points
« Reply #3 on: March 10, 2023, 03:30:06 PM »
When you say "get center" do you mean find the properties of an existing sphere? All you would need is a single selection. Or do you mean, create a sphere?

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #4 on: March 10, 2023, 03:51:10 PM »
I need to get coordinate of center of sphere to draw the point of center because l have a lot of points on a shape i think it is a sphere so i want to pick necessary number of points then draw the center point of the sphere as point and get alert that radius is this all this without drawing the sphere if possible

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #5 on: March 11, 2023, 11:31:11 AM »
Ok if can,t get the answer can be know how to extract the information above from dxf code of a drawen sphere

ribarm

  • Gator
  • Posts: 3257
  • Marko Ribar, architect
Re: get center and radius of sphere by picking 3points
« Reply #6 on: March 11, 2023, 12:02:58 PM »
Sphere as 3DSOLID entity has center point (vla-get-center VLA-OBJECT)... But if you need to create SPHERE, you haven't answered to my question - 3 points in WCS give circle - do you want sphere from that circle, or 4 points not coplanar whereas each triangle has normal xline through center of circumscribed triangle and at intersections of those XLINEs, you obtain center point... Radius is pretty easy : R=(distance cenpt pttriang)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #7 on: March 11, 2023, 12:38:27 PM »
Ok from 4 points

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #8 on: April 04, 2023, 06:17:54 PM »
here is the lisp that can draw the single sphere that passing 4 points
Code - Auto/Visual Lisp: [Select]
  1. ;by engineer motee malazi syria
  2. (defun c:sp4p (/)
  3.   (setq P1(getpoint"\ pick FIRST point OF SPHERE "))
  4.   (setq P2(getpoint"\ pick SECOND point OF SPHERE "))
  5.   (setq P3(getpoint"\ pick THIRD point OF SPHERE "))
  6.   (setq P4(getpoint"\ pick FOURTH point OF SPHERE "))
  7.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.   (setq osmd(getvar"osmode"))
  9.   (setq A1(CAR P1)
  10.         B1(CADR P1)
  11.         C1(CADDR P1)
  12.         )
  13.   (SETQ E1(-(+(* A1 A1)(* B1 B1)(* C1 C1))))
  14.   (setq A2(CAR P2)
  15.         B2(CADR P2)
  16.         C2(CADDR P2)
  17.         )
  18.   (SETQ E2(-(+(* A2 A2)(* B2 B2)(* C2 C2))))
  19.   (setq A3(CAR P3)
  20.         B3(CADR P3)
  21.         C3(CADDR P3)
  22.         )
  23.   (SETQ E3(-(+(* A3 A3)(* B3 B3)(* C3 C3))))
  24.   (setq A4(CAR P4)
  25.         B4(CADR P4)
  26.         C4(CADDR P4)
  27.         )
  28.   (SETQ E4(-(+(* A4 A4)(* B4 B4)(* C4 C4))))
  29.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30.   (SETQ B5(/(-(* B1 A2)(* B2 A1))A2))
  31.   (SETQ C5(/(-(* C1 A2)(* C2 A1))A2))
  32.   (SETQ D5(/(- A2 A1)A2))
  33.   (SETQ E5(/(-(* E1 A2)(* E2 A1))A2))
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35.   (SETQ B6(/(-(* B2 A3)(* B3 A2))A3))
  36.   (SETQ C6(/(-(* C2 A3)(* C3 A2))A3))
  37.   (SETQ D6(/(- A3 A2)A3))
  38.   (SETQ E6(/(-(* E2 A3)(* E3 A2))A3))
  39.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40.   (SETQ B7(/(-(* B3 A4)(* B4 A3))A4))
  41.   (SETQ C7(/(-(* C3 A4)(* C4 A3))A4))
  42.   (SETQ D7(/(- A4 A3)A4))
  43.   (SETQ E7(/(-(* E3 A4)(* E4 A3))A4))
  44.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  45.   (SETQ C8(/(-(* C5 B6)(* C6 B5))B6))
  46.   (SETQ D8(/(-(* D5 B6)(* D6 B5))B6))
  47.   (SETQ E8(/(-(* E5 B6)(* E6 B5))B6))  
  48.   (SETQ C9(/(-(* C6 B7)(* C7 B6))B7))
  49.   (SETQ D9(/(-(* D6 B7)(* D7 B6))B7))
  50.   (SETQ E9(/(-(* E6 B7)(* E7 B6))B7))
  51.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  52.   (SETQ M(/(-(* E8 C9)(* C8 E9))(-(* D8 C9)(* D9 C8))))
  53.   (SETQ W(/(- E8(* D8 M))C8))
  54.   (SETQ Z0(/(- W)2))
  55.   (SETQ V(/(- E5(+(* C5 W)(* D5 M)))B5))
  56.   (SETQ Y0(/(- V)2))
  57.   (SETQ U(/(- E1(+ M(* C1 W)(* B1 V)))A1))
  58.   (SETQ X0(/(- U)2))
  59.   (SETQ R(SQRT(/(+(* U U)(* V V)(* W W)(* -4 M))4)))
  60.   (setvar"osmode"0)
  61.   (COMMAND"POINT"(LIST X0 Y0 Z0))
  62.   (setvar"osmode"osmd)
  63.   (command"_sphere"(list x0 y0 z0)R)
  64.   (PRINT(LIST X0 Y0 Z0))
  65.   (ALERT(STRCAT"RADIUS="(RTOS R 2 3)))
  66.   )

motee-z

  • Newt
  • Posts: 40
Re: get center and radius of sphere by picking 3points
« Reply #9 on: April 04, 2023, 06:24:39 PM »
autocad can draw sphere from 3 points but there are many spheres can pass three points