www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/02/09:40:46

Message-Id: <3.0.5.32.19981002154028.0098f7f0@dictator.nt.tuwien.ac.at>
X-Sender: tony AT dictator DOT nt DOT tuwien DOT ac DOT at
X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32)
Date: Fri, 02 Oct 1998 15:40:28 +0200
To: djgpp AT delorie DOT com
From: Anton Helm <tony AT dictator DOT nt DOT tuwien DOT ac DOT at>
Subject: Re: Tank Movement
Mime-Version: 1.0

Dear cbroo AT iafrica DOT com (Chris Brooker),

Would you mind giving a valid email address if you expect answers ?

Tony




>This message was created automatically by mail delivery software.
>
>A message that you sent could not be delivered to all of its recipients. The
>following address(es) failed:
>
>  cbroo AT iafrica DOT com:
>    unknown local-part "cbroo" in domain "iafrica.com"





At 07:14 02.10.98 GMT, you wrote:

>Here are the functions:
>
>double dir_degrees(int x1, int y1, int y2, int x2)
>{
>	int v1, v2;
>	double dir;
>	v1 = y1 - y2;
>	v2 = x1 - x2;
>	if (v2 == 0) 
>	 v2++; //Stops division by zero errors
>	dir = 57 * atan(v1 / v2);
>	return dir;
>}

Consider using atan2:


#include <math.h>

double dir_degrees(int x1, int y1, int y2, int x2)
  {
  return  atan2(y1-y2, x1-x2) * 180.0 / PI;
  }




Tony



**************************************************************
Dipl.-Ing. Anton HELM   *T*  mailto:tony AT nt DOT tuwien DOT ac DOT at
Institut fuer           *U*  http://www.nt.tuwien.ac.at/~tony/
Nachrichtentechnik und  *W*  http://www.nt.tuwien.ac.at/
Hochfrequenztechnik     *I*  talkto:tony AT eagle DOT nt DOT tuwien DOT ac DOT at
Guszhausstr. 25/389     *E*  phoneto:+43-1-58801-38920
A-1040 Wien, AUSTRIA    *N*  faxto:+43-1-5870583
**************************************************************
finger -l tony AT penguin DOT nt DOT tuwien DOT ac DOT at      for PGP public key
**************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019