Distance

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Hesam Adrang
Posts: 5
Joined: Thursday 19 June, 2014 - 08:52

Distance

Post by Hesam Adrang »

Hi Dears
How can we import the distance between two atoms in the ED?
User avatar
Nienke Valkhoff
Posts: 20
Joined: Tuesday 11 January, 2011 - 09:23

Re: Distance

Post by Nienke Valkhoff »

Hello Hesam Adrang

The easiest 4DScript word to use is AtomDistance(e1,e2) where e1 and e2 are reference to the atoms between which you need to know the distance. The unit of measurement for distance is meters.

You can also calculate the distance using words for querying the location of an atom: xLoc(e1), yLoc(e1), zLoc(e1) where e1 is a reference to the atom of which you need to know the location. Note that the location will be relative to the Container. For atoms such as a Source, Queue and Server the container is usually the Model itself.

The (x,y)- location of an atom is the location of the top left corner of the atom. Use xSize and ySize in combination with xloc and yloc to get the other coordinates. Note that AtomDistance will also return the distance between the topleft corners of teh atom assuming they are on the same z-location.

In the Help of Enterprise Dynamics you can find more information for words in the category Atom Position: 4DScript Reference Guide > 4DScript Categories > 4DScript Category Atom Position. All 4DScript words in this category deal with the location, size and speed of atoms.The 4DScript word AtomDistance(e1,e2) can be found in in the Help in: 4DScript Reference Guide > 4DScript Categories > Category Network > AtomDistance

Regards,

Nienke
Chiara
Posts: 30
Joined: Thursday 20 September, 2012 - 09:40

distance between atoms in different containers

Post by Chiara »

Hello,

I have a question about distance between atoms.
Functions like xloc and xAbsLoc give the position relative to the container of the selected atom, but there's a function able to return the position between atoms that are not in the same container?
I tried to write my own function, a sort of roto-translation function, but it doesn't work properly. I think that the trouble is with the large number of containers in which my atom are (and their differrent rotationas). The new function AbsRotationAs is helpfull but doesn't fix my errors.

What can I do?

Thanks
Chiara
Posts: 30
Joined: Thursday 20 September, 2012 - 09:40

Re: Distance

Post by Chiara »

Sorry,

I didn't specify: I need the distance decomposed in xdistance and ydistance.
Can I calculate the distance by using "atomdistance" and then "sin"/"cos" functions in order to obtain the x/y component?

Thanks
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Distance

Post by HarryBunnik »

Ha Chiara,

Perhaps I'm not understanding your question, but using xAbsLoc the location is determined in relation to the second parameter ( which must be an atom in which the first parameter/atom is located). When the second parameter is a reference to the model and you do so for both the atoms you're interested in, it's only a matter of subtracting the xAbsLoc(atom_1, model) and the xAbsLoc(atom_1, model) and to repeat that for the yAbsLoc for both atoms I would think.

I hope this helps you a bit further,

Cheers,

Harry
Chiara
Posts: 30
Joined: Thursday 20 September, 2012 - 09:40

Re: Distance

Post by Chiara »

Hi Harry,

the trouble is that I don't really need the distance as final objective, I thougth I could use it to obtain the position in coordinates of an atom expressed in the cartesian system coordinates of the other.

For example:
Immagine.jpg
Immagine.jpg (67.25 KiB) Viewed 8716 times
I would know the coordinates of the black atom in relation to the sky-blue atom (that is, -6,-4) even if they aren't in the same container.
I wold find a procedure, a formula to do that, because I don't know the position of the balck atom (maybe it could be over the other one or not, I don't know).

Thank you so much,

Chiara
Chiara
Posts: 30
Joined: Thursday 20 September, 2012 - 09:40

Re: Distance

Post by Chiara »

Anybody?!
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Distance

Post by HarryBunnik »

Ha Chiara,

Sorry for my late response. I had missed your earlier post.

I'm afraid that I'm again lost in what you try to achieve. You want to know the position of the Black atom. Do you have a reference to that atom (first(c), next(c), last(c), i, rank(#, model) or something else)? If you do, you can get the coordinates as I pointed on earlier (left upper corner of the atom is its xLoc, yLoc and zLoc). When you use xLoc, you get it for the local Cartesian system. And with xAbsLoc you get it related to the model.
If you have from both atoms the coordinates related to the model, I would think you can calculate it back to system of the atom you're interested in?

Cheers,

Harry
Post Reply