Author Topic: Angle Precision  (Read 2425 times)

0 Members and 1 Guest are viewing this topic.

BazzaCAD

  • Guest
Angle Precision
« on: July 12, 2007, 08:35:28 PM »
How do you increase the angle Precision in LSP?
I'm getting the rotation angle of an ATTRIB.
It returns: AttAng = 1.5708 (i.e. 90 Degrees)
Then I check it...
(> AttAng (* 0.5 pi))
& get T, So I know there's some rounding going on, how do I fix it ? :)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Angle Precision
« Reply #1 on: July 12, 2007, 08:42:51 PM »
What you're seeing is display precision, not internal precision.

Try this --

(rtos attang 2 15)
(rtos (* 0.5 pi) 2 15)

What do you see?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Angle Precision
« Reply #2 on: July 12, 2007, 08:53:47 PM »
Rather than use a decimal approximation of an angle, why not use the angle itself ...

i.e. if you need to make a 90 degree calculation, use

Code: [Select]
(setq AttAng (angtof "90"))

Then when you run this code
Code: [Select]
(= AttAng (* 0.5 pi))

The result is T
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Angle Precision
« Reply #3 on: July 12, 2007, 08:59:48 PM »
Keith -- isn't he retrieving the angle from an entity (an attribute) rather than setting it explicitly?

That's how I read it; maybe I'm wrong. It happens.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Angle Precision
« Reply #4 on: July 12, 2007, 09:00:42 PM »
..........So I know there's some rounding going on, how do I fix it ? :)


Warm and Fuzzy

(equal expr1 expr2 [fuzz])

(equal MyAng (* PI 0.5) 1.0e-14)  ; << adjust fuzz for  requirements
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BazzaCAD

  • Guest
Re: Angle Precision
« Reply #5 on: July 12, 2007, 10:14:53 PM »
Thx for the advice guys.
They're all really helpful.
I'll be getting the angle from an ATTRIB, then setting it if needed.
Basically the overall goal is to make them all Right Reading...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Angle Precision
« Reply #6 on: July 13, 2007, 08:21:25 AM »
Keith -- isn't he retrieving the angle from an entity (an attribute) rather than setting it explicitly?

That's how I read it; maybe I'm wrong. It happens.

:)

You are correct ...
However, either his attribite is not at 90 degrees or he has read the attribute angle from a list and approximated it in the variable.

Insert a block with an attribute at 90 degrees
Check it with this code
Code: [Select]
(=  (cdr (assoc 50 (entget (car (nentsel))))) (* pi 0.5))

It will return T, however if the attribute is not at 90 deg, it will always return nil i.e. if it is at 90.0000001 or anything other than exactly 90 degrees it will return nil.

Use of a fuzz factor in this instance, as Kerry pointed out, will resolve the issue as can be evidenced in this code. Use the same attribute, but rotate it slightly ... say 90.01 deg

Code: [Select]
(equal (cdr (assoc 50 (entget (car (nentsel))))) (* pi 0.5) 0.01 )
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie