Multiple rotations in OnPaint

Hi,

I have 2 "triangles" which are drawn by 3 drawLines each in the Paint of the form.

Those 2 triangles need to be rotated but with a different angle.

So let us say : triangle 1 :45° , triangle 2: -75°.

Is this possible to do this

Grtz

Annihil8



Answer this question

Multiple rotations in OnPaint

  • PoorSQLGuy

    Ok,

    and which formula would that be

    Trigonometric functions in C# are they degrees/radian

    Arctan is that the inverse of tan

    grtz,

    Annihil8


  • Rick Strahl

    u can use trignometric functions (sin, cos and tan, arctan) for find the point (screen pixel) and draw line to that point.

    Regards,
    Sudeesh.


  • WayneSpangler

    pretty sure the trig functions are default in radians. They were for me, anyway.
  • Nfrf

    public Point RotatePoint(Point pPoint,Point pOrigin,Single degrees)

    {

    Point rotatePoint=new Point();

    rotatePoint.X = Convert.ToInt32(pOrigin.X + (Math.Cos(D2R(degrees))*(pPoint.X - pOrigin.X) - Math.Sin(D2R(degrees))*(pPoint.Y - pOrigin.Y)));

    rotatePoint.Y = Convert.ToInt32(pOrigin.Y + (Math.Sin(D2R(degrees))*(pPoint.X - pOrigin.X) + Math.Cos(D2R(degrees))*(pPoint.Y - pOrigin.Y)));

    return rotatePoint;

    }

    public double D2R(double Angle)

    {

    return Angle / 180 * Math.PI;

    }

    This works for me :) I thought I needed to use matrix.rotateAt.


  • Multiple rotations in OnPaint