normalizing from a divided value

hey all,

have come to a road block and could really do with some help, so any would be appreciated and thanks before hand.

Now how to explain this

alt text

looking at this really awesome best drawing in the world how would i go about finding a value on the green line if i supply the hour and minute of the hour?

thanks for any help

int max = 24;

float portionOfMax = (max * (float)ableToGetThisPercent);

int eighteen =  ((int)portionOfMax / 6); //disregard remainder by casting to int; For example 7/2 = 3


float pcnt_between_eighteen_and_max =  Math.inverseLerp(eighteen, max, portionOfMax)

thanks for the reply, i think i understand the logic but what would ableToGetThisPercent be?

This is a strange range you want there. You are aware of the fact that the sub sections are not qually distributed? The sections all have a length of “6” but your target ranges have a length of 0.5 for the first and last and a length of 1 for the two in the middle. So this is not a linear mapping and therefore can’t be solved with a linear expression.

Though you get the result you want by doing this:

public static float Remap(float aVal)
{
    aVal /= 6f;
    int section = Mathf.FloorToInt(aVal);
    aVal -= section; // aVal now in the range 0 - 1
    if (section == 0)
        return 0.5f + aVal * 0.5f;
    else if (section == 3)
        return aVal * 0.5f;
    return aVal;
}

Are you sure you want this progression? It means the value will suddenly jump from 1 to 0 at an input value of 6, 12 and 18

**wont let me post as comment

the jump from 0 to 1 doesnt cause any problems so far cause i switch the tod i was lerping to > to the tod i was lerping from< so its pretty seamless

ill try that now in a sec, what float would i supply to aVal?

this is what i have so far which works perfect except for the lerping involved with the first range

public void LerpSkySetting(float h, float min)
    {
 
        float TimeValue = (float)h + ((float)min / 60.0f);
        TimeValue /= 6.0f;
 
        float OutputValue;
 
        int hour;
        int nextHour;
        if (TimeValue <= 1.0f)
        {
            // 1st Quadrant - return value between 0.5 and 1.0
            hour = 0;
            nextHour = 1;
            OutputValue = TimeValue - 0.5f;
           
        }
        else if (TimeValue <= 2.0f)
        {
            hour = 1;
            nextHour = 2;
            // 2nd Quadrant - return value between 0.0 and 1.0
            OutputValue = TimeValue - 1.0f;
        }
        else if (TimeValue <= 3.0f)
        {
            hour = 2;
            nextHour = 3;
            // 3rd Quadrant - return value between 0.0 and 1.0
            OutputValue = TimeValue - 2.0f;
        }
        else
        {
            hour = 3;
            nextHour = 0;
            // 4th Quadrant - return value between 0.0 and 0.5
            OutputValue = (TimeValue - 3.0f) / 2.0f;
        }
 
        float t = OutputValue;
 
        print(t);
        currentSkySettings.directionalLightColor = Color.Lerp(TODGroups[0].timeSettings[hour].directionalLightColor, TODGroups[0].timeSettings[nextHour].directionalLightColor, t);
        currentSkySettings.directionalLightIntensity = Mathf.Lerp(TODGroups[0].timeSettings[hour].directionalLightIntensity, TODGroups[0].timeSettings[nextHour].directionalLightIntensity, t);
        currentSkySettings.sunSize = Mathf.Lerp(TODGroups[0].timeSettings[hour].sunSize, TODGroups[0].timeSettings[hour].sunSize, t);
        currentSkySettings.shadowIntensity = Mathf.Lerp(TODGroups[0].timeSettings[hour].shadowIntensity, TODGroups[0].timeSettings[nextHour].shadowIntensity, t);
        currentSkySettings.ambientIntensity = Mathf.Lerp(TODGroups[0].timeSettings[hour].ambientIntensity, TODGroups[0].timeSettings[nextHour].ambientIntensity, t);
        currentSkySettings.skyTint = Color.Lerp(TODGroups[0].timeSettings[hour].skyTint, TODGroups[0].timeSettings[nextHour].skyTint, t);
        currentSkySettings.skyGround = Color.Lerp(TODGroups[0].timeSettings[hour].skyGround, TODGroups[0].timeSettings[nextHour].skyGround, t);
        currentSkySettings.exposure = Mathf.Lerp(TODGroups[0].timeSettings[hour].exposure, TODGroups[0].timeSettings[nextHour].exposure, t);
        currentSkySettings.atmosphereThickness = Mathf.Lerp(TODGroups[0].timeSettings[hour].atmosphereThickness, TODGroups[0].timeSettings[nextHour].atmosphereThickness, t);
        InputSetting();
    }

float FindingValueOfTheGreenLine(float hours, float minutes)
{
minutes = (minutes + hours * 60 + 1080) % 1440;
int unit = minutes < 720 ? 360 : 720;
return minutes % unit / unit;
}
@danipren my first code was a bit complicated :smiley:
This function will return the correct value on the green line for your hours and minutes input