+ Reply to Thread
Results 1 to 6 of 6

How to Draw an arc which is 1/4 of a circle?

  1. #1
    Johannes
    Guest

    How to Draw an arc which is 1/4 of a circle?

    Is there a way to draw an arc which is 1/4 of a circle?
    It looks like Shapes.addcurve only draw bezier curve, but how do I make the
    curve a 1/4 of a circle?

    I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it to
    draw 1/4 of a circle.



  2. #2
    Bernard Liengme
    Guest

    Re: How to Draw an arc which is 1/4 of a circle?

    Excel was not designed for this
    --
    Bernard V Liengme
    www.stfx.ca/people/bliengme
    remove caps from email

    "Johannes" <[email protected]> wrote in message
    news:[email protected]...
    > Is there a way to draw an arc which is 1/4 of a circle?
    > It looks like Shapes.addcurve only draw bezier curve, but how do I make
    > the
    > curve a 1/4 of a circle?
    >
    > I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it to
    > draw 1/4 of a circle.
    >
    >




  3. #3
    Tushar Mehta
    Guest

    Re: How to Draw an arc which is 1/4 of a circle?

    As Bernard noted, XL really isn't ideal for this, but you can use the
    Office-level capabilities to your advantage. Turn on the macro
    recorder (Tools | Macro > Record new macro...) to get the code for the
    below:

    Create a circle with the Drawing toolbar's Oval button (hold down SHIFT
    to force a circle rather than a generic oval).

    Select this circle and copy + Paste Special | Image (PNG) format.

    Select the pasted object and from the Picture toolbar (it should show
    up automatically when the graphic is selected), use the Crop button to
    crop the appropriate horizontal 1/2 and the appropriate vertical 1/2.

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <[email protected]>,
    [email protected] says...
    > Is there a way to draw an arc which is 1/4 of a circle?
    > It looks like Shapes.addcurve only draw bezier curve, but how do I make the
    > curve a 1/4 of a circle?
    >
    > I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it to
    > draw 1/4 of a circle.
    >
    >
    >


  4. #4
    Andy Pope
    Guest

    Re: How to Draw an arc which is 1/4 of a circle?

    Hi,

    Here is a function that will draw a freeform arc.
    The separate x and y radius allow you to draw ovals.

    '-------------------------------
    Sub FourQuadarents()
    Dim shpArc As Shape

    Set shpArc = CreateArc(100, 100, 0, 90)
    Set shpArc = CreateArc(100, 100, 90, 180)
    Set shpArc = CreateArc(100, 100, 180, 270)
    ' colour segement
    CreateArc(100, 50, 270, 360).Fill.ForeColor.SchemeColor = 43

    End Sub

    Function CreateArc(XRadius As Single, YRadius As Single, _
    StartAngle As Single, EndAngle As Single) As Shape
    '
    Dim intAngle As Integer
    Dim dblA1 As Double
    Dim dblB1 As Double
    Dim dblA2 As Double
    Dim dblB2 As Double
    Const PI = 3.14159265358979

    With ActiveSheet.Shapes.BuildFreeform( _
    msoEditingAuto, XRadius, YRadius)
    For intAngle = StartAngle To EndAngle
    dblA2 = XRadius + (Cos((intAngle * (PI / 180))) * XRadius)
    dblB2 = YRadius - (Sin((intAngle * (PI / 180))) * YRadius)
    .AddNodes msoSegmentLine, msoEditingAuto, dblA2, dblB2
    Next
    .AddNodes msoSegmentLine, msoEditingAuto, XRadius, YRadius
    Set CreateArc = .ConvertToShape
    End With

    End Function

    Cheers
    Andy

    Johannes wrote:
    > Is there a way to draw an arc which is 1/4 of a circle?
    > It looks like Shapes.addcurve only draw bezier curve, but how do I make the
    > curve a 1/4 of a circle?
    >
    > I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it to
    > draw 1/4 of a circle.
    >
    >


    --

    Andy Pope, Microsoft MVP - Excel
    http://www.andypope.info

  5. #5
    Jean Ruch
    Guest

    Re: How to Draw an arc which is 1/4 of a circle?


    "Johannes" <[email protected]> schrieb im Newsbeitrag
    news:[email protected]...
    > Is there a way to draw an arc which is 1/4 of a circle?
    > It looks like Shapes.addcurve only draw bezier curve, but how do I

    make the
    > curve a 1/4 of a circle?
    >
    > I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it

    to
    > draw 1/4 of a circle.



    hello Johannes,

    You always have the possibility to use standard equations of a cicle
    (in cartesian or better polar coordinates)

    You will for example get half a circle with positive y-values and
    centered on the origin
    (simplest version) if you put:

    in Column AA from A3 to A39 a series from 0 to 180, step 5

    in column B (standing for x= OP *cos (theta) = rho * cos (theta))
    with the formula
    in B3=2*$E$1*COS(D3*PI()/180)

    The figure in E1 stands for the radius of your circle

    in column C, corresponding to y = OPsin Theta = rho sin Theta with the
    Formula

    in C3 =2*$E$1*SIN(D3*PI()/180)

    Make your diagram from the Range B3:C39

    If you want a complete circle centered on the origin,

    complete the series in Column A up to 360
    and copy down the formulas in Columns B and C
    the new range for your diagram will be B3:C75


    take care that the x and y axes have the same absolute size for the
    same values....

    If you want only the first quadrant ( in the trigonometric sense),
    limit the Diagram

    for equivalent 0 to 90 ° i.e use the Range B3:C21


    You are free to choose any angle you want for the beginning of your
    curve
    (the first column corresponds to values in °); Your 1/4 circle should
    end for a value in ° incremented with + 90 in your first Column)


    regards

    Jean


  6. #6
    Jon Peltier
    Guest

    Re: How to Draw an arc which is 1/4 of a circle?

    One of the AutoShapes is an arc, and if you hold down Shift while drawing it, the
    arc will be constrained to equal height and width. If you turn on the macro
    recorder, you will get the following code:

    ActiveSheet.Shapes.AddShape(msoShapeArc, 350.25, 63.75, 114#, 114#).Select

    where the four numerical arguments are the left, top, width, and height of the arc.
    The default height is the top right (North to East) quadrant of the circle, but you
    can use a combination of

    Selection.ShapeRange.Flip msoFlipHorizontal
    Selection.ShapeRange.Flip msoFlipVertical

    to orient the arc the way you want it.

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______

    Johannes wrote:
    > Is there a way to draw an arc which is 1/4 of a circle?
    > It looks like Shapes.addcurve only draw bezier curve, but how do I make the
    > curve a 1/4 of a circle?
    >
    > I also tried Shapes.BuildFreeForm().AddNodes(), but I couldn't get it to
    > draw 1/4 of a circle.
    >
    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1