Float in einer List,
Verfasst: Dienstag 23. Oktober 2007, 10:37
Servus,
ich habe mal eine Frage zu Floats in einer List.
ich habe zwei Listen mit den Werten im Beispiel.
meine erste Frage dazu ist, wenn ich den topVector1 ausgebe dann bekomme ich die Werte die auch drin sind, wenn ich aber nur topVector1[0] ausgebe dann bekomme ich eine "kuerzere" Zahl heraus!
meine zweite Frage ist, width ergibt das Ergebnis 23.0, und wird durch 0.5 dividiert, das Ergebnis von tileAcross ist 46.0. aber wenn ich es dann als int(tileAcross) ausgebe bekomme ich 45!!!
[code=py]
import math
tilesize=0.5
topVector1=[69.448009935042961, 3.2652270793914795, 8.1317279836453142]
topVector2=[85.711465902333543, 3.2652270793914795, -8.1317279836452787]
width=math.sqrt((math.pow(topVector2[0]-topVector1[0],2))+(math.pow(topVector2[1]-topVector1[1],2))+(math.pow(topVector2[2]-topVector1[2],2)))
tilesAcross= (width/tilesize)
[/code]
ich habe mal eine Frage zu Floats in einer List.
ich habe zwei Listen mit den Werten im Beispiel.
meine erste Frage dazu ist, wenn ich den topVector1 ausgebe dann bekomme ich die Werte die auch drin sind, wenn ich aber nur topVector1[0] ausgebe dann bekomme ich eine "kuerzere" Zahl heraus!
meine zweite Frage ist, width ergibt das Ergebnis 23.0, und wird durch 0.5 dividiert, das Ergebnis von tileAcross ist 46.0. aber wenn ich es dann als int(tileAcross) ausgebe bekomme ich 45!!!
[code=py]
import math
tilesize=0.5
topVector1=[69.448009935042961, 3.2652270793914795, 8.1317279836453142]
topVector2=[85.711465902333543, 3.2652270793914795, -8.1317279836452787]
width=math.sqrt((math.pow(topVector2[0]-topVector1[0],2))+(math.pow(topVector2[1]-topVector1[1],2))+(math.pow(topVector2[2]-topVector1[2],2)))
tilesAcross= (width/tilesize)
[/code]