[vtkusers] Float to Int
Patrícia Gonçalves
pgoncalves at inegi.up.pt
Wed Jul 19 05:33:14 EDT 2006
I'm not familiar with Tcl and I don't know if it has a Round method, but you can make one yourself:
float j = (number);
int i = j; // making i equal to the floor of (number)
if (j-i>=0.5) i=i+1;
Hope to have been of help!
----- Original Message -----
From: Ali
To: Patrícia Gonçalves
Sent: Tuesday, July 18, 2006 7:33 PM
Subject: Re: [vtkusers] Float to Int
Hi, i'm using tcl/tk and not C++. I'm fairly new to tcl/tk, do you know
the syntax?
Thanks.
Patrícia Gonçalves wrote:
> Hi!
>
> I'm not sure I understood your problem...
>
> I imagine you have something like this:
>
> float j = 0.8983f;
> int i = (int)j;
>
> making i=0.
>
> If you're using .NET you can use the Math::Round method:
>
> float j = 0.8983f;
> int i = (int)Math::Round(j);
>
> making i=1.
>
> Hope this helps!
> <http://www.inegi.up.pt>
>
>
>
> ----- Original Message -----
> *From:* Ali Calvert <mailto:fcukered at gmail.com>
> *To:* vtkusers at vtk.org <mailto:vtkusers at vtk.org>
> *Sent:* Tuesday, July 18, 2006 5:33 PM
> *Subject:* [vtkusers] Float to Int
>
> Hi all, i'm having a bit of difficulty converting my texture
> coordinates (as a float from 0 -> 1) to a coordinate (as an
> integer from 0 - > size of image) My current method simply floors
> the float, i.e. 0.8983 would be a 0, however this isn't very
> accurate as it should be a 1.
>
> Can anybody help me please?
>
> Also if there is a better way of doing this rather than rounding,
> i would appreciate any comments.
>
> Thank you for your time.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060719/a352387c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 23294 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060719/a352387c/attachment.jpeg>
More information about the vtkusers
mailing list