What's wavelenght of laser

About advanced scenes, and the Thyme scripting language used in Algodoo.

What's wavelenght of laser

Postby Fastpulse91 » Mon Jan 15, 2018 6:17 pm

Hello,

Could you say me, what's the wavelenght of the laser associate to color,
and can i modify or add new wavelenght by scripting?

thank you
Fastpulse91
 
Posts: 3
Joined: Sun Jan 14, 2018 1:29 am

Re: What's wavelenght of laser

Postby Kilinich » Tue Jan 16, 2018 10:41 am

Here it is an example how to convert wavelength to RGB color:

Code: Select all
scene.my.gamma = 1.0;
scene.my.wave2RGB := (wavelength) => {
    wave := math.toFloat(wavelength);
    attenuation := 0; R := 0; G := 0; B := 0;
    (wave >= 380 && wave < 440) ? {
        attenuation = 0.3 + 0.7 * (wave - 380) / (440 - 380);
        R = ((-(wave - 440) / (440 - 380)) * attenuation) ^ scene.my.gamma;
        G = 0.0;
        B = (1.0 * attenuation) ^ scene.my.gamma;
    } : {};
    (wave >= 440 && wave < 490) ? {
        R = 0.0;
        G = ((wave - 440) / (490 - 440)) ^ scene.my.gamma;
        B = 1.0;
    } : {};
    (wave >= 490 && wave < 510) ? {
        R = 0.0;
        G = 1.0;
        B = (-(wave - 510) / (510 - 490)) ^ scene.my.gamma;
    } : {};
    (wave >= 510 && wave < 580) ? {
        R = ((wave - 510) / (580 - 510)) ^ scene.my.gamma;
        G = 1.0;
        B = 0.0;
    } : {};
    (wave >= 580 && wave < 645) ? {
        R = 1.0;
        G = (-(wave - 645) / (645 - 580)) ^ scene.my.gamma;
        B = 0.0;
    } : {};
    (wave >= 645 && wave < 750) ? {
        attenuation = 0.3 + 0.7 * (750 - wave) / (750 - 645);
        R = (1.0 * attenuation) ^ scene.my.gamma;
        G = 0.0;
        B = 0.0;
    } : {};
    (wave >= 750 || wave < 380 ) ? {
        R = 0.0;
        G = 0.0;
        B = 0.0;
    } : {};
    [R,G,B,1]
}
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: What's wavelenght of laser

Postby Kilinich » Tue Jan 16, 2018 1:13 pm

..or you could use just hue value from colorHSVA(0) and convert it to wave length.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 9 guests

cron