sketchucation logo sketchucation
    • Login
    1. Home
    2. macgile
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 33
    • Groups 1

    macgile

    @macgile

    10
    Reputation
    3
    Profile views
    33
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    macgile Unfollow Follow
    registered-users

    Latest posts made by macgile

    • RE: Subtract two angle

      @tig said:

      Why not use 90.degrees etc and return the angle.radians to see what it is in degrees too... skip all of the PI and radian confusion...

      =====> I tested with 90.degrees, but I thought it was the conversion that was bad

      Why are you making your axe/up vectors so complex ?
      Your figures are off too...
      axe = Geom::Vector3d.new(-0.999782867743517, -0.0208378829670674, 0.0)

      =====> because it is real vectors returned with axe.inspect
      I was given a real example.

      Which is a very tiny number that's ALMOST zero

      This is a a simple tolerance issue...

      ======>Tolerance has importance here because it is cumulative.

      BUT to test for tiny values use something like:

      a 'rounding' method - here to 6dp.

      angle=(angle*106).round.to_f/106
      angle==0
      true

      This will then trap for these tiny inaccuracies...

      ...

      posted in Developers' Forum
      M
      macgile
    • RE: Subtract two angle

      thank's Dan Rathbun

      i have sketchup 8 !!!

      it's not angle between, but the subtraction.
      because the calculation of the angle is good.

      posted in Developers' Forum
      M
      macgile
    • Subtract two angle

      Hi all,

      I have a strange result when I subtract two angle in radians!!!!

      example :

      <span class="syntaxdefault">axe </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Vector3d</span><span class="syntaxkeyword">.new(-</span><span class="syntaxdefault">0.999782867743517</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">-</span><span class="syntaxdefault">0.0208378829670674</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.0</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">up </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Vector3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">0.00335712544250249</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">-</span><span class="syntaxdefault">0.161071856847676</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.98693697196954</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">axe</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">normalize</span><span class="syntaxkeyword">!<br /></span><span class="syntaxdefault">up</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">normalize</span><span class="syntaxkeyword">!<br /></span><span class="syntaxcomment"># (90 deg) = 1.5707963267948966 in rad<br />#(Math;;PI/2.0) = 90.0 in degrees, 1.5707963267949 in radians<br /><br /># angle between up-axe = 90.0 in degrees, 1.5707963267949 in radians<br /></span><span class="syntaxdefault">angle </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Math</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PI</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2.0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">up</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">angle_between axe</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">puts angle</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">radians  </span><span class="syntaxcomment">#=> 180 degrees, 3.14159265358979 radians GOOD !!!<br /><br /></span><span class="syntaxdefault">angle </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Math</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PI</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2.0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">up</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">angle_between axe</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">puts angle</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">radians  </span><span class="syntaxcomment">#=> 1.27222187258541e-014 BAD,  2.22044604925031e-016 in radians BAD &nbsp;</span><span class="syntaxdefault"></span>
      

      can you help me ?

      posted in Developers' Forum
      M
      macgile
    • RE: [Plugin] CameraKeyMaker 1.0 (Update 2011-04-09)

      @tig said:

      I do not know this tool in any detail... but in passing... I see that there are $ global variables like '$preview' these are dangerous - especially if they have simplistic names [like 'preview'] as other authors might have used them [ill-advisedly] too, as globals works across all scripts in that session - better to use '@preview' as an instance variable, or '@@preview' as a class variable, to hold your data specifically for your own tool so such potential clashes are avoided... 🤓

      Yes TIG

      when I developed this plugin I had only one months experience the ruby language and API sketchup.
      certainly you will find other errors of this type in the source, but I perfecting every day.
      in the next release several beginner mistakes are corrected but it will remain.

      best regard 😄

      posted in Plugins
      M
      macgile
    • RE: Strange result of a substraction

      @jim said:

      @macgile said:

      I thought the result would be near to 0 and not of 4.

      macguile,

      4.44089209850063e-016

      The e-016 at the end of the number means to move the decimal place 16 places to the left - making the actual number:

      0.0000000000000000444089209850063

      or very nearly zero. The reason the result is not exactly zero is due to floating point errors as linked above.

      thank i nderstand now 😄

      regard

      posted in Developers' Forum
      M
      macgile
    • RE: Strange result of a substraction

      @dan rathbun said:

      A singleton method to increment a float a, by an argument arg, to dec number of decimal places. (It defaults to 1 decimal place.)

      a = 9.0
      > def a.incr( arg = 1.0, dec = 1 )
      >   dec = dec.to_i
      >   arg = round( arg.to_f * 10**dec  )
      >   # self is object a
      >   temp =( round( self * 10**dec ) + arg ).to_f
      >   self =( temp / 10**dec )
      > end
      

      use it like:
      a = 9.0 b = -1.8 a.incr(b)

      THANK for this solution Dan

      Best Regard 😄

      posted in Developers' Forum
      M
      macgile
    • RE: Strange result of a substraction

      @voljanko said:

      @unknownuser said:

      i dont compare anything !!!
      i have tested with a = a + b the result is same

      I just meant that is always good to avoid considering floats as exact numbers.

      oh yes 😄

      I thought the result would be near to 0 and not of 4.

      posted in Developers' Forum
      M
      macgile
    • RE: Strange result of a substraction

      @dan rathbun said:

      @macgile said:

      i have tested with a = a + b the result is same

      That is because the Ruby interpreter converts
      a += b
      to
      a = a + b
      before the expression is evaluated.

      i dont understand your explanation Dan !!!!

      posted in Developers' Forum
      M
      macgile
    • RE: Strange result of a substraction

      @voljanko said:

      This is almost zero 😄
      It is always a risk when you use floats, in all languages.You should never compare float == float if you don't want problems.

      i dont compare anything !!!
      i have tested with a = a + b the result is same

      posted in Developers' Forum
      M
      macgile
    • RE: Link SketchUp with Database

      hi rallouD

      try this : http://pleac.sourceforge.net/pleac_ruby/dbaccess.html

      posted in Developers' Forum
      M
      macgile