# Projecting mesh from single point to geometry

## Recommended Posts

Hello,

Houdini beginner here, I am looking for a solution to project geometry from a given single point (labelled as the green dot in the diagram, just above the mid point of the sphere) to y=0 to make a semisphere.

The point is to have a flat ground without deformations and changes to the UV projection while a camera is positioned at the given point. So say you had a panoramamic image/video applied to the semisphere, it would look undistorted when viewing from this given point.

Edited by nkyms
##### Share on other sites

Hi,

You mean like this?

Then you can just use this inside a Point Wrangle SOP:

if ( @P.y < 0 )
@P.y = 0;

```if ( @P.y < 0 )
@P.y = 0;```

##### Share on other sites

Thanks for the reply.

No, the shape is close to what is intended but what I'd like to do is bring the points in towards the middle.

In theory I need each point below y=0 to move towards 0,0,0 (or a given point) until it hits the y axis.

14 minutes ago, animatrix said:

Hi,

You mean like this?

Then you can just use this inside a Point Wrangle SOP:

if ( @P.y < 0 )
@P.y = 0;

```
if ( @P.y < 0 )
@P.y = 0;```

##### Share on other sites

Like this?

```if ( @P.y < 0 )
@P = 0;```

##### Share on other sites

No, let me reword this.

I'd like to move each point below the y-axis towards the middle until it reaches the y axis.

Meaning the points will not come to a single point. And when viewing from the middle point, each point will still be at the same angle.

I'd use the ray node, but this only allows for a vector direction.

Edited by nkyms
##### Share on other sites

You can Use Clip Sop with Stereo Projection ON any Given Point Or Geo.Have Fun ..You Have Those Methods Here ON OdFroce Investigate

##### Share on other sites

I am aware of Clip Sop however I don't recall there being a Stereo Projection functionality. Could you elaborate on this method?

I've had a search around on the forums, but I still can't find a solution.

Thanks for the help.

##### Share on other sites

27 minutes ago, animatrix said:

Thanks for the help so far.

By bringing the points towards the middle of the initial sphere they should hit the bottom of the semisphere along the x,z plane, sorry I think I confused you by saying y-axis.

The first image you sent is the closest, but the angles of each point viewed from the center are changed. I need each point to be the same angle and projected to the lower base of the semi-circle.

##### Share on other sites

I see yes this can be done using Ray Plane intersection analytically without creating a plane geometry.

I will post an example when i get home.

##### Share on other sites

`v@rayDir = {0, -1, 0};`

Ray.hiplc

##### Share on other sites

Inside view / Outside view:

hemisphere.hipnc

##### Share on other sites

Same result along with greetings from stack overflow:

```string cam = chs('camera');

matrix xform_cam = optransform(cam);
vector pos_cam = cracktransform(0,0,0,0,0, xform_cam);
vector pos_plane = {0,0,0};
vector nml_plane = {0,1,0};

vector dir_line = normalize(v@P - pos_cam);
float scale = dot(nml_plane, pos_plane) - dot(nml_plane, pos_cam) / dot(nml_plane, dir_line);

v@P = pos_cam + dir_line * scale;```

hemisphere_calc.hipnc

• 2
• 1
##### Share on other sites

i don't know if the effect is same as:

- Point SOP

- preset Flatten Bottom

- adjust to whatever level you like (max half way), doesn't have to be exact hemisphere, animatable.

##### Share on other sites

14 hours ago, konstantin magnus said:

Same result along with greetings from stack overflow:

```
string cam = chs('camera');

matrix xform_cam = optransform(cam);
vector pos_cam = cracktransform(0,0,0,0,0, xform_cam);
vector pos_plane = {0,0,0};
vector nml_plane = {0,1,0};

vector dir_line = normalize(v@P - pos_cam);
float scale = dot(nml_plane, pos_plane) - dot(nml_plane, pos_cam) / dot(nml_plane, dir_line);

v@P = pos_cam + dir_line * scale;```

Thanks for the solution.

This did the trick. I still don't really understand what is happening fully in the expression, but I'll have a shot.

##### Share on other sites

You can also use something like this which is similar to Konstantin's approach:

```vector linePlaneIntersection ( vector raypos, raydir, planepos, planedir )
{
vector diff = raypos - planepos;
vector d = dot ( diff, planedir ) / dot ( raydir, planedir );
return raypos - raydir * d;
}

if ( @P.y < 0 )
{
vector n = normalize ( chv("p") - @P );
vector p = linePlaneIntersection ( @P, n, 0, { 0, 1, 0 } );
@P = p;
}```

Depending on the P parameter, the result will change, so make sure to set it to non 0, 0, 0. Otherwise all bottom points will intersect at 0, 0, 0. Here I use 0, 0.3, 0:

Edited by animatrix
##### Share on other sites

10 hours ago, animatrix said:

You can also use something like this which is similar to Konstantin's approach:

```
vector linePlaneIntersection ( vector raypos, raydir, planepos, planedir )
{
vector diff = raypos - planepos;
vector d = dot ( diff, planedir ) / dot ( raydir, planedir );
return raypos - raydir * d;
}

if ( @P.y < 0 )
{
vector n = normalize ( chv("p") - @P );
vector p = linePlaneIntersection ( @P, n, 0, { 0, 1, 0 } );
@P = p;
}```

Depending on the P parameter, the result will change, so make sure to set it to non 0, 0, 0. Otherwise all bottom points will intersect at 0, 0, 0. Here I use 0, 0.3, 0:

Thanks, this works well. I'll have a look at your solution too.

Edited by nkyms

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×