algorithmic modeling for Rhino
Tags:
When you auto-convert a Colour to a Vector, it will remap the RGB channels onto XYZ coordinates. So first of all you lose the information in the Alpha channel, it's gone forever. The mapping of RGB (which are integers between 0 and 255 each) to XYZ which could be any floating point values, is as follows:
Dim factor As Double = 1.0 / 127.5
x = (colour.R * factor) - 1.0
y = (colour.G * factor) - 1.0
z = (colour.B * factor) - 1.0
So if a colour channel has the lowest value of 0, the corresponding coordinate will be -1.0. If the channel has the highest value of 255, the coordinate will be +1.0. In the case of [255,161,161] it does:
Dim factor As Double = 1.0 / 127.5
x = (255 * factor) - 1.0 which equals 1.0
y = (161 * factor) - 1.0 which equals 0.262745 (rounded to 6 decimal places)
z = (161 * factor) - 1.0 which equals 0.262745
So the length of the vector with these xyz coordinates is:
SquareRoot of (1.0² + 0.262745² + 0.262745²) which equals 1.066803 (rounded again)
It also follows the largest possible length of a vector created this way is the Square root of 3, which roughly equals 1.732050
This conversion works both ways incidentally, so as long as you convert unitized vectors into colours you'll always get a non-clipped result.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you for so detailed tutorial! very clear, thank you
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by