⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Mixdown
All Projects
Mixdown
Overview
Activity
Wiki
Download (1.15 KB)
RGB Cube
» HNTE_colourwheel.m
Andrew Kohlsmith
, 03/17/2014 10:33 PM
clc
clear
all
close
all
i
=
0
;
while
i
<
3
for
x
=
0
:
pi
/
100
:
pi
/
2
%do the colour shift
if
i
==
0
r_rad
=
255
*
sin
(
x
);
g_rad
=
0
;
b_rad
=
255
*
cos
(
x
);
elseif
i
==
1
r_rad
=
255
*
cos
(
x
);
g_rad
=
255
*
sin
(
x
);
b_rad
=
0
;
elseif
i
==
2
r_rad
=
0
;
g_rad
=
255
*
cos
(
x
);
b_rad
=
255
*
sin
(
x
);
end
%set the rgb polar angles
r_theta
=
0
;
g_theta
=
2
*
pi
/
3
;
b_theta
=
4
*
pi
/
3
;
%convert from polar coordinates to cartesian
r_x
=
r_rad
*
cos
(
r_theta
);
r_y
=
r_rad
*
sin
(
r_theta
);
g_x
=
g_rad
*
cos
(
g_theta
);
g_y
=
g_rad
*
sin
(
g_theta
);
b_x
=
b_rad
*
cos
(
b_theta
);
b_y
=
b_rad
*
sin
(
b_theta
);
%get the summed colour
sum_x
=
r_x
+
g_x
+
b_x
;
sum_y
=
r_y
+
g_y
+
b_y
;
%convert the sum back to polar coordinates
sum_rad
=
sqrt
(
sum_x
*
sum_x
+
sum_y
*
sum_y
);
sum_theta
=
atan2
(
sum_y
,
sum_x
);
%plot onto a polar figure
p
=
polar
(
sum_theta
,
sum_rad
,
'kS'
);
hold
on
%delete labels
t
=
findall
(
gcf
,
'type'
,
'text'
);
delete
(
t
);
%set the marker to the correct colour
set
(
p
,
'MarkerFaceColor'
,
[
abs
(
r_rad
/
255
)
abs
(
g_rad
/
255
)
abs
(
b_rad
/
255
)],
'MarkerSize'
,
35
);
pause
(
0.02
);
end
i
=
i
+
1
;
end
delete
(
p
);
hold
off
« Previous
1
2
3
4
5
6
…
8
Next »
(4-4/8)
Loading...