How to connect point outlines into lines?

   1063   3   0
User Avatar
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!

Attachments:
FunctionCurve.hiplc (164.8 KB)

User Avatar
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

Attachments:
Screenshot 2023-06-03 164316.png (882.6 KB)
forum_001_functioncurve.hiplc (165.4 KB)

Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
User Avatar
Member
63 posts
Joined: Feb. 2022
Online
Mohanpugaz
i think your values for the variables are too high so you got spiky lines, ive tried smaller numbers it worked perfectly fine

Image Not Found
Thanks for your help, this does indeed do the contour joining.


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?
User Avatar
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.

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