Author Topic: Text position  (Read 3912 times)

0 Members and 1 Guest are viewing this topic.

velasquez

  • Newt
  • Posts: 195
Text position
« on: February 21, 2015, 07:25:02 AM »
To follow a pattern I need to position text on a line in the following figure posted.
I have the points and angles that showed.
P3 and p4 points when I can drag the cursor and they can be above or below the red line.
I tried to help in other post but not very far.
Can anyone give me a way?

ymg

  • Guest
Re: Text position
« Reply #1 on: February 21, 2015, 07:46:58 AM »
velasquez,

Use this function to keep your text at readable angle:

Code - Auto/Visual Lisp: [Select]
  1. ;; Make Angle Readable                                                        ;
  2.  (defun MakeReadable (a)
  3.      (setq a (rem (+ a pi pi) (+ pi pi)))
  4.      (rem (if (< (* pi 0.5) a (* pi 1.5))(+ a pi) a) (+ pi pi))  
  5.   )
  6.  

This will return the angle at which your text shuld be drafted.

ymg

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Text position
« Reply #2 on: February 21, 2015, 08:18:37 AM »
This is what I use:

Code - Auto/Visual Lisp: [Select]
  1. ;; Readable  -  Lee Mac
  2. ;; Returns an angle corrected for text readability.
  3.  
  4. (defun LM:readable ( a )
  5.     (   (lambda ( a )
  6.             (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
  7.                 (LM:readable (+ a pi))
  8.                 a
  9.             )
  10.         )
  11.         (rem (+ a pi pi) (+ pi pi))
  12.     )
  13. )

velasquez

  • Newt
  • Posts: 195
Re: Text position
« Reply #3 on: February 21, 2015, 11:35:25 AM »
Thanks
 I will work with the functions.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Text position
« Reply #4 on: February 22, 2015, 06:48:48 AM »
Similar: http://www.theswamp.org/index.php?topic=47220.0

Small issue: both functions proposed here do not work properly if the input is smaller than -2*pi.
Code: [Select]
(MakeReadable (* -1 pi)) => 0.0
(MakeReadable (* -3 pi)) => -3.14159
(LM:READABLE (* -1 pi)) => 0.0
(LM:READABLE (* -3 pi)) -3.14159

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Text position
« Reply #5 on: February 22, 2015, 07:00:45 AM »
Similar: http://www.theswamp.org/index.php?topic=47220.0

Small issue: both functions proposed here do not work properly if the input is smaller than -2*pi.
Code: [Select]
(MakeReadable (* -1 pi)) => 0.0
(MakeReadable (* -3 pi)) => -3.14159
(LM:READABLE (* -1 pi)) => 0.0
(LM:READABLE (* -3 pi)) -3.14159

Thanks roy - a possible correction:

Code - Auto/Visual Lisp: [Select]
  1. ;; Readable  -  Lee Mac
  2. ;; Returns an angle corrected for text readability.
  3.  
  4. (defun LM:readable ( a )
  5.     (   (lambda ( a )
  6.             (if (< a 0.0)
  7.                 (LM:readable a)
  8.                 (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
  9.                     (LM:readable (+ a pi))
  10.                     a
  11.                 )
  12.             )
  13.         )
  14.         (rem (+ a pi pi) (+ pi pi))
  15.     )
  16. )

ymg

  • Guest
Re: Text position
« Reply #6 on: February 23, 2015, 03:33:01 PM »
Roy,

Maybe this to normalize the angle between 0 and 2pi.

Code: [Select]
(defun MakeReadable (a)
     (if (minusp (setq a (rem  a (+ pi pi)))) (setq a (+ a pi pi)))
     (rem (if (< (* pi 0.5) a (* pi 1.5))(+ a pi) a) (+ pi pi)) 
  )

ymg

efernal

  • Bull Frog
  • Posts: 206
Re: Text position
« Reply #7 on: February 23, 2015, 05:21:17 PM »
Code - Auto/Visual Lisp: [Select]
  1. (DEFUN ef:txt:ang (e)
  2.   (IF (AND (> e (* PI 0.5)) (< e (* PI 1.5)))
  3.     (+ e PI)
  4.     e
  5.   )
  6. )
  7.  
e.fernal

velasquez

  • Newt
  • Posts: 195
Re: Text position
« Reply #8 on: February 28, 2015, 07:47:47 AM »
I'm finishing the code to test all the suggested options.
Great help.

velasquez

  • Newt
  • Posts: 195
Re: Text position
« Reply #9 on: March 03, 2015, 04:13:33 PM »
Similar: http://www.theswamp.org/index.php?topic=47220.0

Small issue: both functions proposed here do not work properly if the input is smaller than -2*pi.
Code: [Select]
(MakeReadable (* -1 pi)) => 0.0
(MakeReadable (* -3 pi)) => -3.14159
(LM:READABLE (* -1 pi)) => 0.0
(LM:READABLE (* -3 pi)) -3.14159






Thanks roy - a possible correction:

Code - Auto/Visual Lisp: [Select]
  1. ;; Readable  -  Lee Mac
  2. ;; Returns an angle corrected for text readability.
  3.  
  4. (defun LM:readable ( a )
  5.     (   (lambda ( a )
  6.             (if (< a 0.0)
  7.                 (LM:readable a)
  8.                 (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
  9.                     (LM:readable (+ a pi))
  10.                     a
  11.                 )
  12.             )
  13.         )
  14.         (rem (+ a pi pi) (+ pi pi))
  15.     )
  16. )



Hi Lee
I tested its corrected function.
She worked well with the angles that I informed:
(LM: readable (angle p1 p2)) or (LM: readable (angle p2 p1)) -> Returns the correct angle

Thanks




Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Text position
« Reply #10 on: March 03, 2015, 04:46:14 PM »
Hi Lee
I tested its corrected function.
She worked well with the angles that I informed:
(LM: readable (angle p1 p2)) or (LM: readable (angle p2 p1)) -> Returns the correct angle

Thanks

Excellent - I'm pleased it works well for you.  :-)