begin # block entire file
function JMWdlgt(Yxy, descrip, vec) begin
global JMW_v0, JMW_v1, JMW_v2, JMWdomain
global LamDomain
# Yxy is a row vector, [Y, x, y]
# vec is the net vector over LamDomain computed from
# Yxy and the usual vectors.
# James Worthey, 1999 December 9
# JMWdomain is the actual domain of the vectors
# of Judd, MacAdam, and Wyszecki, [300, 830]
# Elements 1-60 are lost if LamDomain = [360, 830]
# Initially we ignore this, except for this reminder.
#
# For now Y, "big Y," is the raw tristimulus value,
# not meant to be in meaningful units such as cd/m^2 .
# Ref. W&S 1st edition, pp. 9-13
descrip = ["JMW daylight for [x, y] = [", ...
ntoa( Yxy(2) ),", ", ntoa( Yxy(3) ), "]" ]
Y = Yxy(1)
x = Yxy(2)
y = Yxy(3)
Denom = (0.0241 +0.2562*x -0.7341*y)
M1 = (-1.3515 -1.7703*x +5.9114*y)/Denom
M2 = ( 0.0300 -31.4424*x +30.0717*y)/Denom
xyCheck(x, y)
# for test purpose, at least:
format double ""
# print "scalar multipliers: M1 = ",M1,", M2 = ",M2
vec = JMW_v0 + M1*JMW_v1 + M2*JMW_v2
XYZ = zeros(3)'
YxyNew = zeros(3)'
Ycalc = TriStim(vec, XYZ, YxyNew)
discrep = abs([Yxy(2)-YxyNew(2), Yxy(3)-YxyNew(3) ])
discrep = max( discrep )
NormFactor = Yxy(1)/Ycalc
vec = vec*NormFactor
YxyNew(1) = YxyNew(1)*NormFactor
# if discrep > 0.001 then begin
# msg = "In JMWdlgt.oms, chromaticity doesn't check to 0.001"
# errordlg(msg)
# end # end if discrep > etc.
# print " Yxy = ", Yxy
# print "YxyNew = ", YxyNew
end # end the function JMWdlgt()
function xyCheck(x, y) begin
# Ref: W&S, p. 11
yCurve = 2.870d0*x - 3.000*x*x - 0.275
if x < 0.25 then begin
print "x below min for JMW model by ", 0.25-x
end
if x > 0.38 then begin
print "x above max for JMW model by ", x - 0.38
end
if y - yCurve > 0.008 then begin
print "y above domain for JMW model by ", y-yCurve-0.008
end
if yCurve - y > 0.008 then begin
print "y below domain for JMW model by ", yCurve-y-0.008
end
# print "y - yCurve = ", y-yCurve
end # fn xyCheck(x, y)
end # end blocking entire file