Sunday, May 18, 2008

Assignment #3 Question #2, 3








(If you cannot see the above solution, just double click on the text to see it better.)

This expression does work. Therefore, this expression can compute the relative percentage of colour that is known to lie on the straight line joining two colours.

Another method: Let C be the given colour and let the coordinates be represented by (X0,Y0). The distance between C and C1 can be calculated using the following:

d(C,C1)=sq. root of [(X0-X1)squared +(Y0-Y1)squared]

You can also use the above to calculate the distance between C1 and C2

d(C1,C2)=sq. root of [(X1-X2)squared +(Y1-Y2)squared]

To find the percentage, let P1 represent the percentage of C1 in C by using the following:

P1=[[d(C1,C2)-d(C,C1)]/d(C1,C2)] *100

Once you find P1 finding P2 of C2 is pretty straight forward. Use P2=100-P1.

Question #3
The following expression can compute the relative percentage of colour that is known to lie within the triangle whose vertices are at the coordinates of C1, C2, and C3. Where C1(x1,y1), C2(x2, y2) and C3(x3, y3).
Consider the following:

a1+a2+a3=1
then,
x=a1x1+a2x2+a3x3
y=a1y1+a2y2+a3y3
Consider the following matrices:
[1,1,1;x1,x2,x3;y1,y2,y3]*[a1;a2;a3]=[1;x;y]
If we use the inverse of the first matix above, we determine the following results:
[a1;a2;a3]=[1,1,1;x1,x2,x3,y1,y2,y3]inverse *[1;x;y]

No comments: