HayManMarc
Member
Hey all,
Are you ready? MATH CHALLENGE!!
Are you excited? I hope you're excited. Actually, I'm hoping someone around here is great with maths and can help me out. I do okay with math, and can usually, eventually find the answer for things that are not too complicated, but this one is spinning my brain. I'll start researching and maybe I'll figure it out before someone comes up with a solution, but I thought I'd post this here to get the ball rolling.
Here's a diagram:
I'm trying to make a script that will plot points along the red line. Here are some facts and goals of the script:
I'm trying to make a chain fixture along the arc. I don't think it will help, but here's my code so far:
I don't know if I'm going about this the right way, or the best way. I don't even know for sure if it's even possible to make a formula for this -- if enough information is provided to support a formula. I think there is, but I could be wrong. I'll reply here with the answer if I figure it out on my own.
Here's a preemptive THANK YOU to anyone giving this a shot.
Are you ready? MATH CHALLENGE!!
Are you excited? I hope you're excited. Actually, I'm hoping someone around here is great with maths and can help me out. I do okay with math, and can usually, eventually find the answer for things that are not too complicated, but this one is spinning my brain. I'll start researching and maybe I'll figure it out before someone comes up with a solution, but I thought I'd post this here to get the ball rolling.
Here's a diagram:
I'm trying to make a script that will plot points along the red line. Here are some facts and goals of the script:
- Known variables are shown in the diagram with values. (These variables can be different values as provided by the programmer, so the script will be like a formula.)
- The y2 value should be determined by the script.
- I would like the script to determine the optimal amount of plot points to make a smooth curve, down to 1 degree differences from point to point.
- (For example, if the angle difference between the starting point and the ending point is 60, then there would be a maximum of 60 plot points in the arc. However, if the distance between the starting point and ending point is too small, we'll need fewer plot points and sharper angles.)
I'm trying to make a chain fixture along the arc. I don't think it will help, but here's my code so far:
Code:
/// @function plot_slope(x, y, width, start angle, end angle)
/// @description
/// @param {param_type} param_name description
/// @param {param_type} param_name description
var px = argument0; // starting x position plot (ground fixture)
var py = argument1; // starting y position plot
var pw = argument2; // desired width of plot
var sa = argument3; // starting angle of plot
var ea = argument4; // ending angle of plot
var ad = angle_difference(sa, ea);
/*
I think I need to find the intersection of the perpendicular lines of the starting and ending point vectors,
when the second length equals the first. This will be the center point of the circle that
will bisect both points. (I know what I mean, but I don't know if I wrote this correctly -- sorry.)
*/
var cp = // center point
/*
I assume now we need to determine the optimal number of plot points along the arc.
*/
var cs = // number of curve sections
/*
At this point, I think we can use lengthdir with the angle difference (var ad) of the start and end points divided by the number of plot points (var cs) along the arc.
*/
// ?? Code for this ?? (This is as far as I got tonight. I'm out of steam.)
// NOW CREATE THE CHAIN FIXTURE
var fix = physics_fixture_create();
physics_fixture_set_chain_shape(fix, false);
// ITERATE THOUGH THE POINTS AND CREATE THE CHAIN
for (i = 0; i < cs; i += 1;)
{
???
}
// physics_fixture_add_point(fix, px, py);
physics_fixture_bind(fix, id);
physics_fixture_delete(fix);
Here's a preemptive THANK YOU to anyone giving this a shot.