Please help with the following code, I tried casting, and the such but this keeps getting rounded

public void rotacion(Point[] pts, int degreesIncr)
    {
        
        //here... I tried casting all combinations, even casted each variable, each 
        //number, and nothing, radians keeps being integral. but if I sustitute a 
        // constant number (e.g 80) radians is double, and I dont understand why. 
        //so silly this is.
        double radians =(degreesIncr)*(Math.PI / 180); 
        double sinAngle = Math.Sin(radians);
        double cosAngle = Math.Cos(radians);
        MessageBox.Show(radians.ToString() + "," + sinAngle.ToString() + "," + cosAngle.ToString());
        for (int i = 0; i < pts.Length; ++i)
        {
            pts[i].X = (int)(pts[i].X * (cosAngle) - pts[i].Y * (sinAngle));
            pts[i].Y = (int)(pts[i].Y * (cosAngle) + pts[i].X * (sinAngle));
        }

Recommended Answers

All 3 Replies

Have you tried passing degreesIncr as a double instead of an int?

Also, change the 180 to 180.0.
The compiler interprets 180 as an integer and 180.0 as a double.

Oh, its working now, the problem was in the parameter, I was not passing the intended variable, I feel bad but I was desesperate, maybe next time Ill have some rest first and check the code later before posting, thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.