Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Jewel posted:

It's not the sleepers that's the deformation, I know they'll always deform and it's not realistic, I'm talking about at the 45 degree angle the exposed end of the track is all squashed and short. Though that endpoint tracking + thickness idea is neat.

Translate the midpoint of the exposed end instead, and calculate the track positions off of that? Same basic idea as beta's recommendation for the sleepers.

You only have two points that are free: the centers of the tracks at either end. Everything else should be calculated from those. What are you generating those curves from?

EDIT: The variables I'd use are the center points of the track at either end and two vectors specifying incoming and outgoing directions, and then constrain the tracks to follow a circular arc.:

1. Calculate the radius and center of the circle from the two points and directions.
2. Add or subtract the separation of each line from the center arc.
3. Draw circle arcs of those radii with the same center and subtended angle as the center's arc.

A straight track segment has an infinite radius, so you'll need to special case it.

EDIT2: Like this.

The Laplace Demon fucked around with this message at 07:29 on Dec 27, 2014

Adbot
ADBOT LOVES YOU

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

baka kaba posted:

Yeah this was what I was getting at - treat the midline for each sleeper as between two points, one on each track line, and let the function move the points. You end up with a rotated line and you just need to align the sleeper with that. I guess the slight complication is that tight turns with short spacing will end up trying to cram several sleepers into the inside turn, and you might get overlaps.

But yeah I wasn't sure if the whole thing was the output of a function, like... I guess I'm not very good at explaining this, but like the kind of things you can do with a graphic calculator. Drop in some equation and it traces out the shapes, y'know? If it's a more complex program where you can draw the sleepers separately then it could work out

^^^ That up there looks awesome though, and I love how the internet lets people do things like that to give examples. Hey here's some live animated code!

Thanks! Here it is with sleepers added the way you were describing.

The Laplace Demon fucked around with this message at 18:40 on Dec 27, 2014

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"
Nah, it's more analogous to DBL_MIN.

Mozilla's example for how to use it is delightfully obscure:

Using MIN_VALUE posted:

The following code divides two numeric values. If the result is greater than or equal to MIN_VALUE, the func1 function is called; otherwise, the func2 function is called.

JavaScript code:

if (num1 / num2 >= Number.MIN_VALUE) {
    func1();
} else {
    func2();
}


I guess you know why you might want to do that if you already knew about MIN_VALUE, but absent that context it as might as well be any other constant, e.g.

JavaScript code:

if (num1 / num2 >= Math.SQRT1_2) {
    func1();
} else {
    func2();
}

Hmm, I wonder if there's an example on Math.SQRT1_2's documentation page?

Using Math.SQRT1_2 posted:

The following function returns 1 over the square root of 2:


JavaScript code:

function getRoot1_2() {
    return Math.SQRT1_2;
}

getRoot1_2(); // 0.7071067811865476

:v:

  • Locked thread