distance of vector to other vectors in an array

Hi everybody
the first, i’m sorry if my question looking dumb
I made an basic looping and logic to generate some vectors.
Then i put these vectors in an array.
Now, i wanna get distance of vector to other vectors in array, if it meeting necessary conditions (10<x<20), it would be add to another array.
How can i do it ? Can someone give me an example ?

Vector is just direction and magnitude of it". You cannot calculate distance between 2 vectors. Unless you define how you want to calculate some value, but you need to assume some additional things, what is your version of distance:

  • distance between starting points.
  • distance between end points.
    -maybe distance between middle points
  • distances between lines defined by those 2 vectors.

Now i am guessing. Because in unreal location or vector use same data structure, you in fact want to have distance between points that are stored as 2 “vectors”.

For that simply vector_A - vector_B then use length (vector) node.

For your problem:

  • loop for each trough all vectors
  • if its same vector or same values in both vectors skip them (you do not need to skip, since you have that second condition of length (distance) in some rang.
  • now Vector_A - Vector_B then length
  • check if length is in your range
  • save to next array

ps.
Not sure what you need that for, but to create array of vectors in range 10 … 20 you can do something else:

  • seed random stream
  • generate UNIT vector from random stream
  • generate Float in range 10 … 20 from random stream
  • multiply that random unit vector by that random Float.

pps.
Random Streams are great for making games. If you SEED random stream from same seed you get exactly same numbers each tame you run SMAE code (if code changes order of using random number changes, so results will change).

So seed that random stream with “42” its lucky number and made some company here quite rich. :wink:

1 Like

Thanks @Nawrot i’ll try with your suggest <3 :smiling_face_with_three_hearts: