How to connect point outlines into lines?
1063 3 0- HenDaSheng
- Member
- 63 posts
- Joined: Feb. 2022
- Online
I draw a graph like this through a function, but when I want to use "Add" to connect them into a line, it becomes like this.
Later I found out that the rule of "add" connection is based on the order of point numbers, so it becomes like this.
I want to connect all the points according to the outline of the graph, but I don't know how to realize this connection. Do you have any solution to this problem?
Thank for your help!
- Mohanpugaz
- Member
- 146 posts
- Joined: June 2016
- Offline
i think your values for the variables are too high so you got spiky lines, ive tried smaller numbers it worked perfectly fine
Edited by Mohanpugaz - June 3, 2023 07:16:42
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
- HenDaSheng
- Member
- 63 posts
- Joined: Feb. 2022
- Online
MohanpugazThanks for your help, this does indeed do the contour joining.
i think your values for the variables are too high so you got spiky lines, ive tried smaller numbers it worked perfectly fineImage Not Found
But this method still follows the connection of points, making the shape of the graph uncontrollable. Is it possible to do contour joins while maintaining the shape of the graph?
- HenDaSheng
- Member
- 63 posts
- Joined: Feb. 2022
- Online
I found the problem, there is nothing wrong with the calculation method of the graph, but I missed a very important step in the middle.
In the program, 360° is not 360, but PI*2. The i in the for loop represents radians. The current i is an integer from 1 to 360. This is not the "radian" required in the algorithm, which directly leads to problems in the title.
This problem was solved when I converted i from integer to radians via radians() method.
It can be seen that the point numbers are arranged in sequence according to the position, so that when using add node, you can get a flat outline.
In the program, 360° is not 360, but PI*2. The i in the for loop represents radians. The current i is an integer from 1 to 360. This is not the "radian" required in the algorithm, which directly leads to problems in the title.
This problem was solved when I converted i from integer to radians via radians() method.
vector pos = {0, 0, 0}; int pointsNum = chi("point_num"); float a, b, c, t; a = chf("a"); b = chf("b"); c = chf("c"); t = chf("t"); for(int i = 0; i < pointsNum; i++) { float theta = radians(i); pos.x = cos(a * theta + t) + cos(b * theta + t) / 2 + sin(c * theta + t) / 3; pos.y = sin(a * theta + t) + sin(b * theta + t) / 2 + cos(c * theta + t) / 3; addpoint(0, pos); }
It can be seen that the point numbers are arranged in sequence according to the position, so that when using add node, you can get a flat outline.
-
- Quick Links