You are not logged in.
Pages: 1
Some easy scripts. But they might be useful.
/*
** Usage:
** y3 = line_xtoy (x1,y1, x2,y2, x3)
**
** Arguments:
** x1,y1, x2,y2: coordinates of two points of the line
** x3: x coordinate of third point of the line
**
** Returns:
** y coordinate of third point of the line
**
**
** brac37
*/
{
return ((argument4-argument0)*argument3 +
(argument2-argument4)*argument1) /
(argument2-argument0);
}
/*
** Usage:
** x3 = line_xtoy (x1,y1, x2,y2, y3)
**
** Arguments:
** x1,y1, x2,y2: coordinates of two points of the line
** y3: y coordinate of third point of the line
**
** Returns:
** x coordinate of third point of the line
**
**
** brac37
*/
{
return ((argument4-argument1)*argument2 +
(argument3-argument4)*argument0) /
(argument3-argument1);
}
Offline
Yeah, easy, but a good way to express the operation in a way that people might use. Divide-by-zero is something they will have to watch out for. I can never decide if it is better to return an error value that might be misinterpreted or just allow the error to happen.
I usually do this with x3 = lerp(x1, x2, boxstep(y1, y2, y3)).
Abusing forum power since 1986.
Offline
Pages: 1