none
mahreendr@yahoo.com haroon rashid Graphics Sample ID hmm111 RRS feed

  • Question

  • with love small basic members i am trying to rotate a line around another line  i have tried with ( haroon rashid Graphics Sample ID hmm111) but can not do it the code-( GraphicsWindow.BackgroundColor = "steelblue"
    GraphicsWindow.Width = 1000
    GraphicsWindow.Height = 600

    'miangul 1
    GraphicsWindow.PenColor = "Blue"  
    For i = 1 To 32
      GraphicsWindow.PenWidth = 4
      GraphicsWindow.DrawLine(i * 24, 30, i * 24, 580 )
    endfor
     
      'miangul 2
      GraphicsWindow.PenColor = "yellow"  
    For i = 1 To 32
      GraphicsWindow.PenWidth = 4
      GraphicsWindow.Drawellipse(i * 24, 30, i * 24, 580)
    endfor) i cant upload programs to small basic fourm i am ineed of if somebody can help with regards haroon rashid
    Saturday, May 14, 2016 7:37 AM

Answers

  • * An ID: hmm111  does not exist.

    * Rotate a line around another line  ????

    To 'rotate' a line, you either
     1.) need it as a see Shapes.AddLine and then you can Shapes.Rotate (about its center) or     LDShapes.RotateAbout (about a specified point/pole x,y)
     or
     2.) draw  a new line GraphicsWindow.DrawLine with a different slope, where SB uses the two point form of a   line (x1,y1, x2,y2), so that y = m * x + d with m = (y2-y1)/(x2-x1) = dy/dx = tan(angle)

     Maybe see a translated version (peculiarly there does'nt seem to be an english version):
     https://de.wikipedia.org/wiki/Geradengleichung     (Zweipunkteform)
     https://de.wikipedia.org/wiki/Zweipunkteform

     Donno the engl. equivalent.

    About 2.) see a sample below:

    GraphicsWindow.Top = 0
    GraphicsWindow.Width = 1000
    GraphicsWindow.Height = 600 + 40
    GraphicsWindow.BackgroundColor = "SteelBlue"
    
    'miangul 1
    GraphicsWindow.PenColor = "Blue"
    GraphicsWindow.PenWidth = 4       ' stays as long as you change it again
    
    For i = 1 To 32
      GraphicsWindow.DrawLine(i*24,30, i*24,580)
    EndFor
    
    'miangul 2
    GraphicsWindow.PenColor = "Yellow"  
    For i = 1 To 32
      GraphicsWindow.DrawEllipse(i*24,30, i*24,580)
    EndFor
    
    
    '' *** SAMPLE ***   vary x1,y1  and y2, deg
    '' From fixed Point1 (x1,y1) ...
    x1 = GraphicsWindow.Width / 2
    y1 = GraphicsWindow.Height - 30
    
    '' ... up to end Point2 (x2,y2) with a slope of deg°
    y2 = 30
    deg = 57  ''  [°]   eg. deg°  within ]0, 180[ , counter clockwise from Pnt1(x1,y1)  where 0° = 3h
    
    ' ----------------------------------
    rad = Math.GetRadians(180 - deg)  '' Correction for SB coordinate system and -> [rad]
    x2 = (y2-y1) / Math.Tan(rad) + x1 '' m = dy/dx = (y2-y1)/(x2-x1) = tan(angle)  , m .. slope
    ' ----------------------------------
    
    GraphicsWindow.PenColor = "Red"
    GraphicsWindow.PenWidth = 10
    GraphicsWindow.DrawLine(x1,y1, x2,y2)


    Saturday, May 14, 2016 11:39 AM
    Answerer
  • For the rotation of a line as pointer on a stopwatch I published a program for the Challenge of the month august 2013. The programming code is BSC206-0 

    Perhaps this is something you are looking for.


    Jan [ WhTurner ] The Netherlands

    Saturday, May 14, 2016 3:29 PM
    Answerer

All replies

  • * An ID: hmm111  does not exist.

    * Rotate a line around another line  ????

    To 'rotate' a line, you either
     1.) need it as a see Shapes.AddLine and then you can Shapes.Rotate (about its center) or     LDShapes.RotateAbout (about a specified point/pole x,y)
     or
     2.) draw  a new line GraphicsWindow.DrawLine with a different slope, where SB uses the two point form of a   line (x1,y1, x2,y2), so that y = m * x + d with m = (y2-y1)/(x2-x1) = dy/dx = tan(angle)

     Maybe see a translated version (peculiarly there does'nt seem to be an english version):
     https://de.wikipedia.org/wiki/Geradengleichung     (Zweipunkteform)
     https://de.wikipedia.org/wiki/Zweipunkteform

     Donno the engl. equivalent.

    About 2.) see a sample below:

    GraphicsWindow.Top = 0
    GraphicsWindow.Width = 1000
    GraphicsWindow.Height = 600 + 40
    GraphicsWindow.BackgroundColor = "SteelBlue"
    
    'miangul 1
    GraphicsWindow.PenColor = "Blue"
    GraphicsWindow.PenWidth = 4       ' stays as long as you change it again
    
    For i = 1 To 32
      GraphicsWindow.DrawLine(i*24,30, i*24,580)
    EndFor
    
    'miangul 2
    GraphicsWindow.PenColor = "Yellow"  
    For i = 1 To 32
      GraphicsWindow.DrawEllipse(i*24,30, i*24,580)
    EndFor
    
    
    '' *** SAMPLE ***   vary x1,y1  and y2, deg
    '' From fixed Point1 (x1,y1) ...
    x1 = GraphicsWindow.Width / 2
    y1 = GraphicsWindow.Height - 30
    
    '' ... up to end Point2 (x2,y2) with a slope of deg°
    y2 = 30
    deg = 57  ''  [°]   eg. deg°  within ]0, 180[ , counter clockwise from Pnt1(x1,y1)  where 0° = 3h
    
    ' ----------------------------------
    rad = Math.GetRadians(180 - deg)  '' Correction for SB coordinate system and -> [rad]
    x2 = (y2-y1) / Math.Tan(rad) + x1 '' m = dy/dx = (y2-y1)/(x2-x1) = tan(angle)  , m .. slope
    ' ----------------------------------
    
    GraphicsWindow.PenColor = "Red"
    GraphicsWindow.PenWidth = 10
    GraphicsWindow.DrawLine(x1,y1, x2,y2)


    Saturday, May 14, 2016 11:39 AM
    Answerer
  • For the rotation of a line as pointer on a stopwatch I published a program for the Challenge of the month august 2013. The programming code is BSC206-0 

    Perhaps this is something you are looking for.


    Jan [ WhTurner ] The Netherlands

    Saturday, May 14, 2016 3:29 PM
    Answerer
  • Saturday, May 14, 2016 3:30 PM
    Answerer