Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problems with getting a 2D distance formula to work in vertexdata

Author
Message
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 23rd Feb 2010 07:35
Hi guys I can't believe i'm posting this
I'm having some problems trying to use a distance formula that tells me how far dummy.ObjNum is away from the vertexes of another object.

I mean this should be easy as pie to make this work.
here is my code


darkvee
Masqutti
16
Years of Service
User Offline
Joined: 8th Jan 2010
Location: insanity
Posted: 23rd Feb 2010 08:29
Hi!

What are you actually meaning to do? It seems that the code true, counts the distance to each vertex of the coolobject, but after each for -loop overwrites the previous calculation with the new value, leaving you finally the distance of the last vertex ^^

Is the problem not calculating at all(returning zero), returning weird numbers or.. ? :S

hmmmh.. that didn't compile
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 23rd Feb 2010 08:58 Edited at: 23rd Feb 2010 09:25
hi Masqutti
If dummy.ObjNum is close to coolObject.ObjNum
the distance is way off. For example use spacekey to randomize the positions then see if you can get the yellow cube next to the red cube. It will say distance 50.0 or higher right next to it.

That means the vertexes should be very close, because coolObject.ObjNum is very close to dummy.ObjNum.

here is the code that shows it should be working
Also I got it were it gets the lowest vertex position , but still problems.
Notice the dummy.Distance is way off compared to dummy.Distance2


darkvee
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Feb 2010 11:24
Vertexdata is relative to the object position. To get the global position of a vertex you have to add its vertexdata position in x to that of the parent object in x (etc.)...

darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 23rd Feb 2010 11:43
Hi thanks backlash! I got it working now

darkvee

Login to post a reply

Server time is: 2026-07-27 07:33:52
Your offset time is: 2026-07-27 07:33:52