hadeedji
Arrange points in circle with a Sweep parameter
His images are swapped, if he divides by count he'll get the problem on right side of the image.
total angle = 180.
increment = 180/8 = 22.5
The last point is 7 increments after the first, so at angle 157.5, not 180 as expected
there really are 2 different things he wants to do. At sweep = 1, he wants to place uniformally on a circle, where the distance between first and last is same as distance between any other. But for sweep = 0.5, he wants to place the points uniformally on a line, where first and last are on the edges
8 replies
Arrange points in circle with a Sweep parameter
Things is, there's really 2 different things you are doing, trying to find a unifying formula that does both is impossible.
There can be multiple solutions to your problem, you can handle the 1.0 case separately, but this will give weird behavior when sweep is close to 1.0. You can try setting a threshold near 1.0 that you determine empirically, where you use different formulas depending on if it's above or below it. You can use a bool paramater to switch between the two. You can decide which approach to use depending on how the function is going to be used
8 replies
✅ Positional record with alternate constructor
Yeah, got it what you're saying
This was an example, in general shouldn't it be possible to have a second constructor for a record that takes some other parameter and initializes it? In some situations that would be a good idea. Say you have a color record with rgb bytes, and want to initialize it with a float vector3. I don't get why it isn't allowed
What's really throwing me off is that the compiler isn't allowing something, but by adding
: this(0, 0)
it lets me do it. But I don't wanna add that in, looks like an anti pattern or code smell. What are your thoughts? Maybe when an anti pattern makes the thing you want to do work, the thing you want to do isn't a good idea?19 replies