Simpler solution to this geometry/trig problem? i had a geometry/trignometry problem come up at work today, and i've been out of school too long: i've lost my tools.
i'm starting with a rectangle of known width (w) and height (h). For graphical simplification i can convert it into a right-angle triangle:

i'm trying to find the coordinates of that point above which is perpendicular to the origin:

i've labelled the opposite angle t1 (i.e. theta1, but Microsoft Paint cannot easily do greek and subscripts), and i deduce that the two triangles are similar (i.e. they have the same shape):

Now we come to my problem. Given w and h, find x and y.
Now things get very difficult to keep drawing graphically, to explain my attempts so far.
But if i call the length of the line segment common to both triangles M:

then:
M = w∙sin(t1)

Now i can focus on the other triangle, which i'll call O-x-M:

and use trig to break it down, giving:
x = M∙sin(t1)
  = w∙sin(t1)∙sin(t1)

y = M∙cos(t1)
  = w∙sin(t1)∙cos(t1)

with
t1 = atan(h/w)

Now this all works (i think, i've not actually tested it yet), and i'll be giving it to a computer, so speed isn't horribly important.
But my god, there must have been an easier way to get there. i feel like i'm missing something.

By the way, what this will be used for is drawing a linear gradient in along that perpendicular:

 A: An equation for the hypotenuse of the right triangle is $y=-\frac{h}{w}x+h$.  Its slope is $-\frac{h}{w}$ (change in $y$-coordinate over change in $x$-coordinate).  The slope of any line perpendicular to the hypotenuse is $\frac{w}{h}$ (perpendicular lines have slopes with product $-1$, or it is sometimes said that the slope of a perpendicular line is the "opposite reciprocal"), so an equation for the line through the origin and perpendicular to the hypotenuse is $y=\frac{w}{h}x$.  The point you want is the solution to the system of equations: $$\begin{align}y&=-\frac{h}{w}x+h\\y&=\frac{w}{h}x\end{align}$$
These equations give two expressions that are both equal to $y$, so set them equal: $$-\frac{h}{w}x+h=\frac{w}{h}x$$ and solve:$$h=\left(\frac{w}{h}+\frac{h}{w}\right)x=\frac{w^2+h^2}{wh}x$$  $$x=\frac{h^2w}{w^2+h^2}$$
Use one of the original equations to find $y$: $$y=\frac{w}{h}x=\frac{hw^2}{w^2+h^2}$$

edit Working from Hans Lundmark's answer, final method, a vector from the origin to the desired point is in the same direction as $\langle\frac{1}{w},\frac{1}{h}\rangle$ or equivalently $\langle h,w\rangle$.  The distance from the origin to the desired point is the length of the altitude—call this $d$.  Looking at the area of the triangle, it is both $\frac{1}{2}wh$ and $\frac{1}{2}d\sqrt{w^2+h^2}$, so $d=\frac{wh}{\sqrt{w^2+h^2}}$.  The desired vector is thus 
$$\begin{align}
\frac{\langle h,w\rangle}{|\langle h,w\rangle|}d
&=\frac{\langle h,w\rangle}{\sqrt{w^2+h^2}}\frac{wh}{\sqrt{w^2+h^2}}
\\
&=\frac{\langle h,w\rangle wh}{w^2+h^2}
\\
&=\left\langle\frac{h^2w}{w^2+h^2},\frac{w^2h}{w^2+h^2}\right\rangle
.\end{align}$$
A: Parametrize the line from $(w,0)$ to $(0,h)$ by $(w,0) + t(-w, h)$. Then you are searching for the point $(x,y)$ on the line such that $(x,y)\cdot (-w,h) = 0$. 
A: Another way: You have identified some angles as being equal in your last figure. This implies that several of the right triangles in the picture are similar. For example,
$$ \frac{h}{w} = \frac{x}{y} = \frac{y}{w-x},$$
from which it is not too difficult to solve for $x$ and $y$.
And yet another: The hypotenuse lies on the line with equation $x/w+y/h=1$ (since the two points $(x,y)=(w,0)$ and $(x,y)=(0,h)$ satisfy this equation, and two points uniquely determine a line). The normal vector to a line can be read off from the coefficients of $x$ and $y$; it is $\mathbf{n}=(1/w,1/h)$ in this case. The point that you seek (let me call it $(a,b)$ here) lies on the line which goes from the origin in the direction that $\mathbf{n}$ points, so the point must be of the form $(a,b)=t \mathbf{n} = (t/w,t/h)$ for some number $t$. Substituting $(x,y)=(t/w,t/h)$ into the equation for the hypotenuse gives $t(1/w^2+1/h^2)=1$, from which we immediately find $t$ and hence also
$$(a,b)=\left( \frac{1/w}{1/w^2+1/h^2}, \frac{1/h}{1/w^2+1/h^2} \right).$$
A: Suppose $h = (h_1,h_2)$ and $w = (w_1, w_2)$. Then you know the slope of the line. Let's call this $m_1$. You also know that the line perpendicular to the point $(x,y)$ has slope $-\frac{1}{m_1}$. You get a system of equations. 
A: For fun, here's another approach ...
The area of your triangle is given by $\frac{1}{2} w h$, but it's also given by $\frac{1}{2}s m$, where $s$ is the length of the hypotenuse and $m$ is the length of your segment $M$. (To see why, flip the triangle over so that it's sitting on its hypotenuse; then, clearly, $s$ is the "base" and $m$ the "height".) Therefore,
$$w h = s m$$
Writing $\theta$ for the angle that segment $M$ makes with the horizontal, we have that 
$$x = m \cos\theta = \frac{wh}{s}\cos\theta \hspace{0.5in} y = m\sin\theta = \frac{wh}{s}\sin\theta$$
By similar triangles, $\theta$ is also the angle in the top corner of your triangle, so
$$\cos\theta = \frac{h}{s} \hspace{0.5in} \sin\theta = \frac{w}{s}$$
and we have
$$x = \frac{wh^2}{s^2}=\frac{w h^2}{w^2+h^2} \hspace{0.5in} y = \frac{w^2 h}{s^2}=\frac{w^2h}{w^2+h^2}$$
