Strange results from a simple if statement?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  12 December 2008
Strange results from a simple if statement?

Hi all

I am very new to maxscript and am receiving really wierd results from a simple if statement, I cannot understand what I am doing wrong so forgive me if this may seem trivial to you.

What I am doing is generating a random amount of faces, some that are perpendicular to the z-axis and others that are not. Problem is, at random intervals the statement returns false when in actual fact it should be returning true. This is happening even if all face normals are exactly the same.

for i=1 to faceNum do
(
p = polyOp.getFaceNormal $ i
if p == [0, 0, 1] then
(
print "true"
)
else
(
print "false"
)
)

At the moment p = [0,0,1] at every increment of i and yet I am still getting falses every now and again. What am I doing wrong?

Thanks in advance
Luca
 
  12 December 2008
Originally Posted by Maxscript Reference: Returns the face normal of the face. If <poly> is a node, or if <poly> is an Editable Poly and <node> is specified, the direction vector returned is in the current coordinate system context. If <poly> is an Editable Poly and <node> is not specified, the return value is in the poly's local coordinate system.
According to the help the direction returned is the current coordinate system, so what coordinate system are you working in?

-Eric
__________________
"The Evil Monkey hiding in your closet."
 
  12 December 2008
Thanks for the speedy reply Pixel_monkey.

Well I havent specified node so I would pressume it is the poly's local co-ordinate system that I am working in. What confuses me is that for every instance that I print 'p' ( about 500 times) it returns constantly a value equal to [0,0,1] and yet it returns random false statements when in effect that should never be happening.
 
  12 December 2008
Hi, it's not a problem with the 'if', it's a precision and display problem. For example you can do this in the listener:


   f = 1.000001 
   1.0
   p = [0,0,f]
   [0,0,1]
   p == [0,0,1]
   false
   

Check out Bobo's answers to this thread for a good explanation
 
  12 December 2008
aaahhh, thanks so much for the help dr. I really appreciate it.
 
  12 December 2008
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:46 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.