Jump to content

with help with basic programming in C#

Mimimimi
public partial class Form1 : Form

    {

        int xKomp, yKomp;

        double angle, magnitude;

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            xKomp = Convert.ToInt16(textBoxXKomp.Text);

            yKomp = Convert.ToInt16(textBoxYKomp.Text);

            double sumquad = (double)(Math.Pow(xKomp, 2) + Math.Pow(yKomp, 2));

            magnitude = Math.Pow(sumquad,0.5);

            label1.Text = betrag.ToString();

 

            if (xKomp != 0)

            {

                angle = Math.Atan2(yKomp, xKomp);

                

            }

                if (angle <0)

           {

             angle = angle + Math.PI;

 

          }

 

so this is my coding, but for some reason when i try xKomp= 3, and yKomp = 4.. the angle should be 0.927 which is < than 0, it wont go thorugh the last part when angle<0.

having exam soon.. really appreciate your help.

Link to comment
Share on other sites

Link to post
Share on other sites

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

The crocodile eats the big number lol how i learnt it when i was like 7 and still sometimes say it that way in my head 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×