# Topic awaiting preservation: Triangle Ratio Help - *Massive* brain fart (Page 1 of 1)

warjournal

From:
Insane since: Aug 2000

posted 03-30-2005 20:04

This is driving me nuts. I know it's a simple ratio and I can see the pieces, but my brain just can't put them together.

Lxyz is known
Lin is known

How do I find Smax?

I've been staring at this for 2 hours and doing remedial research, but I still can't get it.
I know it's simple, but I can't see the *whole* thing for some reason.

Kind of funny.
I'm not embarressed or ashamed or anything.
Just tremenduously frustated over something extremely simple.
I think this is a sign that I need a serious vacation or something.

warjournal

From:
Insane since: Aug 2000

posted 03-30-2005 20:08

Uh...

Smax = 255 * ( Lin - Lxyz ) / ( 255 - Lxyz)

I need a drink.

warjournal

From:
Insane since: Aug 2000

posted 03-30-2005 20:19

Stupid bomb.
Found it.
Nothing left here to see.

OlssonE
Maniac (V) Inmate

From: Eagleshieldsbay, Sweden
Insane since: Nov 2001

posted 03-30-2005 21:17

*gives warjournal some whisky*

Bipolar (III) Inmate

From: United States
Insane since: Mar 2005

posted 03-30-2005 21:35

lol, I got all excited over a new math problem... but, I'll drink to your mathematical success!

warjournal

From:
Insane since: Aug 2000

posted 03-30-2005 22:42

Don't worry, Nada. I'm sure I'll eventually get a really, really good one for you to sink your teeth into.

Looks like my triangle method is wrong. Instead of a hypotenuse, looking like I'm going to need a 1/4 circle. Or I'm missing a little bit of something else. Now that I've taken a walk and am over my brain fart, I might be able to get what I'm going for.

Oh, the joys of reverse-engineering Adobe's priority.

edit:
Captain Morgan + Coke

edit2:
Ah, fuckit.
Linear hypotenuse is close enough.

(Edited by warjournal on 03-30-2005 22:43)

(Edited by warjournal on 03-30-2005 22:54)

hyperbole
Paranoid (IV) Inmate

Insane since: Aug 2000

posted 03-31-2005 16:46

warjournal,

quote:
Smax = 255 * ( Lin - Lxyz ) / ( 255 - Lxyz)

Don't you have a divide by 0? I assume from your figure Lxyz = 255. It that case

code:
`Smax = 255 * (Lin - 255)/(255-255)`

I asume from your drawing that Lxyz is the vertical line.

Let me cahnge your notation a little.

code:
```Let deltaX be the length of the horizontal line
deltaY be the legnth of the vertical line
Y be the known point on the vertical line
X is the value you are looking for

then
x = deltaX/deltaY * (y - deltaY)```

In your case I think that translates to

code:
```Smax = 255/255 * (Lin - 255)
or
Smax = Lin - 255```

If you want this to be a circular intrpolation, I think the following will work:

code:
`x = y / tan(asin(y))`

This formula assumes you're only woking in the first quadrant.

.

-- not necessarily stoned... just beautiful.

warjournal

From:
Insane since: Aug 2000

posted 03-31-2005 19:15

Here is the chunk that I settled on:

code:
```Lxyz =rt*0.30 + gt*0.59 + bt*0.11;
sat=G;

// this upper part seems to be working
if(B>Lxyz){
Smax=255* ((255-B)/(255-Lxyz));
if (sat>Smax){sat=Smax;}
} // B > Lxyz

// still something wrong here
if(B<Lxyz){
Smax=(B/Lxyz)*255;
if (sat>Smax){sat=Smax;}
}```

In that code, B = Lin. I did G = sat substitute because I was having a data type problem that I haven't sorted out. I understand the need for strict data type stuff, but I still have some bad habits from too many years of BASIC.

It's working pretty dandy in damn near every case. The only time it fails is when extremely 'illegal' values are used. For example, Sat=255 and Lum=255. But even when it fails, it's still fairly close. For the vast majority of work, the failing shouldn't be a problem.

I don't think there will be a need to dig into trig.
As much as I love trig, I hate working with trig in FM.
Mixed blessing.

Also, I haven't ran into a division by zero error yet.
Might have to see if I can induce this just too see.

All of this should lead to better integration of my junk with PS's junk.

I'm off to exercise my fingers and wrists some more.
Maybe even dust off some of my old text books.