Have 1 Edge of A circle Polygon always point to -z?

   1934   6   1
User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
Hello so i`ve been trying to figure out the math
(or another hacky solution.)

To make one Face always point to -z ( the face is sometimes the avg of 3 or 4 faces 4.)
Edited by NicTanghe - March 10, 2021 10:29:27

Attachments:
wRkvX4BOrI.gif (1.8 MB)
TEmpleExFin.hipnc (523.6 KB)

User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
here, set up your foundation like this so that prim 0 will ALWAYS face Z, no matter how many sides there are in your foundation.

(I picked Z instead of -Z...just easier to see for me, same difference)
Edited by vusta - March 10, 2021 15:33:43

Attachments:
FaceZ.jpg (346.7 KB)
vu_FaceZ.hipnc (73.7 KB)

User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
How did you arrive at that formula ?
Btw thx u a hero.
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
NicTanghe
How did you arrive at that formula ?
Btw thx u a hero.
just worked it out on the fly i think...so a circle is just an identical segment being incrementally rotated until it perfectly joins
back on itself so i started with 360/N...that didn't quite work out so i simply tried 180/N...that magically worked with one side constantly facing X direction, then it's a simple case of offsetting by 90...so really didn't set out with any fancy formula in mind, just do something...see something....then deal with it.
User Avatar
Member
670 posts
Joined: Sept. 2013
Online
You can rotate an edge to an axis with:

int pts[] = expandedgegroup(0, 'single_edge');

vector pos_0 = point(0, 'P', pts[0]);
vector pos_1 = point(0, 'P', pts[1]);
vector dir = normalize(pos_1 - pos_0);
matrix3 rot = dihedral(dir, {1,0,0});

v@P -= avg(pos_0, pos_1);
v@P *= rot;

Attachments:
edge_to_axis.hipnc (235.6 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
Domo arigato gozaimasu.
User Avatar
Member
190 posts
Joined: Dec. 2016
Offline
SO i tried to change the setup with adding a extra vertex to so it takes the edge that goes from the start of 1 edge to the end of another.

and adjuster the code to int pts = expandedgegroup(0, 'single_edge');

```
vector pos_0 = point(0, 'P', pts);
vector pos_1 = point(0, 'P', pts);
vector dir = normalize(pos_1 - pos_0);
matrix3 rot = dihedral(dir, {1,0,0});

v@P -= avg(pos_0, pos_1);
v@P *= rot;
```

this did not immediately work.
I will do more testing tomorrow and then be back. But i don't c why it doesn't work. I also do not exactly understand what expandededgegroup actually does.
or does it indeed just appoint the edges new numbers from 0-1 ?

Edit it seems in my example and basically when aplying a hacky way is just to resaple the edge to 1 edge.
Edited by NicTanghe - March 17, 2021 09:13:11
  • Quick Links