# How to connect points?

14 replies to this topic

### #1 Prabu

Prabu

Peon

• Members
• 11 posts
• Joined: 07-May 11
• Location:Bournemouth
• Name:Praburaj Rathinam

Posted 02 February 2012 - 08:08 AM

Hello everybody,

I have a set of points( static particles). their pt numbers are not ordered one But it has unique id and nearest point id stored in an attribute  and their distance to nearest point stored in an attribute.
How to connect those pts with their nearest pt. All the suggestions are welcome. Is there any simple solution?

Thanks
-Prabu

Edited by Prabu, 02 February 2012 - 08:09 AM.

### #2 vectorblur

vectorblur

Illusionist

• Members
• 255 posts
• Joined: 05-November 10
• Location:India
• Name:Gaurav Mathur

Posted 02 February 2012 - 10:56 AM

Prabu, on 02 February 2012 - 08:08 AM, said:

Hello everybody,

I have a set of points( static particles). their pt numbers are not ordered one But it has unique id and nearest point id stored in an attribute  and their distance to nearest point stored in an attribute.

Thanks
-Prabu

You can sort points using any existing attribute.
Use sort by expression and supply the variable.

Quick hip is attached.

Cheers,

#### Attached Files

Eh *munch munch* what sop, doc?

### #3 eetu

eetu

Illusionist

• Members
• 480 posts
• Joined: 30-May 07
• Location:Helsinki, Finland
• Name:eetu m

Posted 02 February 2012 - 11:08 AM

I think the point was to create a line from each point to it's nearest neighbor.

Maybe ForEach?

Or create as many lines as you have points, and for each line move vertex 0 to the point that has the same number as the line primitive, and vertex 1 to the point that the previous point's nearest-attribute points to.
(contrieved? naah.)
A shitty theory is better than no theory at all

### #4 Prabu

Prabu

Peon

• Members
• 11 posts
• Joined: 07-May 11
• Location:Bournemouth
• Name:Praburaj Rathinam

Posted 02 February 2012 - 11:20 AM

eetu, on 02 February 2012 - 11:08 AM, said:

I think the point was to create a line from each point to it's nearest neighbor.
Exactly...

eetu, on 02 February 2012 - 11:08 AM, said:

Maybe ForEach?
Yes, But how? could you please elaborate it.

Edited by Prabu, 02 February 2012 - 11:21 AM.

### #5 vectorblur

vectorblur

Illusionist

• Members
• 255 posts
• Joined: 05-November 10
• Location:India
• Name:Gaurav Mathur

Posted 02 February 2012 - 11:23 AM

Ah.. sorry prabhu looks i have misread the question

Could you post the hip ? i dont know why i still find it little confusing.
Eh *munch munch* what sop, doc?

### #6 Prabu

Prabu

Peon

• Members
• 11 posts
• Joined: 07-May 11
• Location:Bournemouth
• Name:Praburaj Rathinam

Posted 02 February 2012 - 11:51 AM

vectorblur, on 02 February 2012 - 11:23 AM, said:

Ah.. sorry prabhu looks i have misread the question

Could you post the hip ? i dont know why i still find it little confusing.
Sure...
I have attached the file.

Thanks
-prabu

### #7 eetu

eetu

Illusionist

• Members
• 480 posts
• Joined: 30-May 07
• Location:Helsinki, Finland
• Name:eetu m

Posted 02 February 2012 - 12:02 PM

Something like this?

#### Attached Files

A shitty theory is better than no theory at all

### #8 eetu

eetu

Illusionist

• Members
• 480 posts
• Joined: 30-May 07
• Location:Helsinki, Finland
• Name:eetu m

Posted 02 February 2012 - 12:09 PM

Prabu, on 02 February 2012 - 11:51 AM, said:

Sure...
I have attached the file.

Your file is one level of redirection harder - the nearest neighbor does not refer to the point numbers but the particle IDs.

If you click on the "Use Point Numbers Instead of Particle IDs" in your Proximity POP you will have it a bit easier.
A shitty theory is better than no theory at all

### #9 kustaa

kustaa

Peon

• Members
• 12 posts
• Joined: 20-May 09
• Location:helsinki finland
• Name:kustaa vuori

Posted 02 February 2012 - 12:32 PM

Ive been using pythonSop to generate geometry. for connecting every point to each other(limited with maxDist) would be something like this in pythonSop:

```geo = hou.pwd().geometry()

maxDist = 5.0
points = geo.points()

pointNum = 0

for p1 in points:
for p2 in points:
if p1.number() != p2.number():
if p2.number() >= pointNum:
pos1 = p1.position()
pos2 = p2.position()
line = pos1 - pos2
length = line.length()
if length < maxDist:
poly = geo.createPolygon()
poly.setIsClosed(False)
posMid = (pos1+pos2)*0.5

iter = 0.0
for pos in pos1, posMid, pos2:
point = geo.createPoint()
point.setPosition(pos)
iter += 1
pointNum = pointNum+1
```

Kustaa

### #10 pclaes

pclaes

Initiate

• Members
• 718 posts
• Joined: 07-October 06
• Location:Method Studios, Los Angeles
• Name:Peter Claes

Posted 04 February 2012 - 04:39 PM

kustaa, on 02 February 2012 - 12:32 PM, said:

Ive been using pythonSop to generate geometry. for connecting every point to each other(limited with maxDist) would be something like this in pythonSop:
Kustaa

If you would want to speed this up a lot, then you could do the length and closest points calculation in vex/vops (multithreaded) beforehand and in your python code, you would read the attribute values and only create the geometry.

### #11 kustaa

kustaa

Peon

• Members
• 12 posts
• Joined: 20-May 09
• Location:helsinki finland
• Name:kustaa vuori

Posted 05 February 2012 - 12:44 AM

pclaes, on 04 February 2012 - 04:39 PM, said:

If you would want to speed this up a lot, then you could do the length and closest points calculation in vex/vops (multithreaded) beforehand and in your python code, you would read the attribute values and only create the geometry.
thats true, on top of being multithreaded im sure that the pc functions are slightly more efficient than my approach =)

### #12 anim

anim

Houdini Master

• Members
• 987 posts
• Joined: 23-August 07
• Location:Slovakia, Bratislava
• Name:Tomas Slancik

Posted 13 February 2012 - 10:16 PM

what about just using forEachSOP in point mode and bring another point in according to nearest attribute and join them together?

Tomas Slancik
Generalist
Slovakia

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users