heise online · c't · iX · Technology Review · Telepolis · mobil · Security · Netze · heise open · heise resale · Autos · c't-TV · Jobs · Kiosk
Zum Inhalt
c't

c't Projekte - c't-Bot und c't-Sim - Mailinglisten

c't-Bot und c't-Sim


[Voriger (Datum)] [Nächster (Datum)] [Voriger (Thread)] [Nächster (Thread)]
[Nach Datum][Nach Thread]

RE: AW: [ct-bot] Abstandsberechnung in sensor_abstand

Absender: Menzel, Frank IT-OO4
Datum: Mo, 28.08.2006 16:19:51
In-reply-to: <44F2F9F0.8060404@xxxxxxxx>


...ja jetzt, die Version vorher hatte dies noch nicht drin und trotzdem ging die Division durch 0 ohne irgendwelche Exceptions... Gab nur ein Müllergebnis... 


Mit freundlichem Gruß
Frank Menzel

-----Original Message-----
From: ct-bot-entwickler-bounces@xxxxxxxxxxxxxxxxx [mailto:ct-bot-entwickler-bounces@xxxxxxxxxxxxxxxxx] On Behalf Of Benjamin Benz
Sent: Monday, August 28, 2006 4:13 PM
To: Entwicklung rund um den c't-bot
Subject: Re: AW: [ct-bot] Abstandsberechnung in sensor_abstand

Frank Menzel wrote:
> Hallo,
> dies ist keine Antwort auf die Frage. Aber das Wegstecken der Division 
> durch 0 ist mir auch schon aufgefallen. Ein paar Zeilen tiefer in der 
> sensor.c heißt es:
> /* Schnittpunkt berechnen */
> 				xd=(a2-a1)/(s1-s2);
> 				yd=(s1*a2-s2*a1)/(s1-s2);
> 
> Und s1-s2 ist durchaus 0, bereits zum Startzeitpunkt. Die Antwort 
> würde mich auch interessieren.

Die ist ganz einfach. Wenn Sie den Code ein paar Zeilen darüber mitlesen:

/* Geradeausfahrt? (s1==s2) */
if (s1==s2) { /* Bei Geradeausfahrt ist v_left==v_right==v_center */
  v_mou_left=v_mou_right=v_mou_center;
} else {
  /* y-Achsenabschnitte berechnen */
  a1=old_y-s1*old_x;
  a2=y_mou-s2*x_mou;
  /* Schnittpunkt berechnen */
  xd=(a2-a1)/(s1-s2);
  yd=(s1*a2-s2*a1)/(s1-s2);

  ...
}
So wird der Sonderfall s1==s2 vorher abgefangen.

MfG Benjamin Benz


--
Benjamin Benz
Heise Zeitschriften Verlag
Redaktion c't
eMail: bbe@xxxxxxxx
WWW  : http://www.heise.de


_______________________________________________
ct-bot-entwickler Mailingliste
ct-bot-entwickler@xxxxxxxxxxxxxxxxx
http://www.heise.de/bin/newsletter/listinfo/ct-bot-entwickler


Confidentiality note:
The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.




Copyright © 2007 Heise Zeitschriften Verlag Kritik, Anregungen bitte an c't-WWW Datenschutzhinweis   Impressum