I'm attempting some crazy ideas while programming a game and ran into the following math problem that has been bugging me for a few days:

Given a unit circle and a random point $P$ within the circle, what is the equation that maps an absolute value function such as $y = 1 - |1-x|$ so that the left side passes through the origin, the right side passes through the $P$, and the apex of the absolute value function is on the circle? If it helps, I'm only concerned with the upper-right quadrant.

The end result would be an isosceles triangle with side lengths 1 (the radius) that treats the circle as a kind of reflective surface, but the reflection is like that of a horizontal surface (reversing only y, not x.) I figured the circle "height" function as $y = \sqrt{1-x^2}$ but I'm not sure how to use it to create an absolute value function that also passes through $(0,0)$ and $P$. Any help would be appreciated.

  • $\begingroup$ Are you saying you want to find a transformation of the absolute value function $y=|x|$? $\endgroup$ – Ataraxia Jun 2 '13 at 10:56
  • $\begingroup$ The left side and right side...of what or whom?? $\endgroup$ – DonAntonio Jun 2 '13 at 10:57
  • 1
    $\begingroup$ A picture would be a big help $\endgroup$ – bubba Jun 2 '13 at 11:36
  • $\begingroup$ Your question is unclear. Can you sktech the "absolute value" function in the plane that contains the origin, the point $P$ and the apex ? $\endgroup$ – Yves Daoust Apr 18 '16 at 6:37

A general form of all absolute value functions (translated and scaled) is


There are three conditions. The equation must pass through the origin:


The apex must lie on the unit circle:


And the equation must pass through $P=(p_x,p_y)$:


In order to find an absolute value function that satisfies these requirements, you will need to solve these three simultaneous equations for $a$, $b$, and $k$.

  • $\begingroup$ Thank you for your response. I did not think to use the general form of the absolute value function. That would mean a, b, k are functions of P, correct? So the equation I'm looking for is y = fa(px,py) + fk(px,py) * abs(x + fb(px,py)) where fa, fb, and fk are functions that return the appropriate modifiers a, b, and k for the absolute value function from the given P. But can I find a, b, and k independently from each other using only P? $\endgroup$ – Jeremy Robson Jun 3 '13 at 9:29

The statements in the answer you already have are all correct. Here is a more explicit way to solve the necessary equations, assuming the coordinates of $P$ are $(p_x,p_y)$ and both coordinates are positive.

The apex of the desired function lies on the intersection of the line $y=\frac{p_y}{p_x} x$ and the circle $x^2 + y^2 = 1$, so it is the point $$A = \left(\frac{p_x}{\sqrt{p_x^2 + p_y^2}}, \frac{p_y}{\sqrt{p_x^2 + p_y^2}}\right).$$ The condition that the function passes through the origin determines that for $x < \frac{p_x}{\sqrt{p_x^2 + p_y^2}}$, the function must follow the formula $$y = \frac{p_y}{p_x} x, \tag1$$ and your "reflection" condition requires that for $x > \frac{p_x}{\sqrt{p_x^2 + p_y^2}}$, the function must follow the formula $$y = \frac{p_y}{\sqrt{p_x^2 + p_y^2}} - \frac{p_y}{p_x}\left(x - \frac{p_x}{\sqrt{p_x^2 + p_y^2}}\right).\tag2$$

We can put this all together in one equation that gives the function value for any real number $x$,

$$y = \frac{p_y}{\sqrt{p_x^2 + p_y^2}} - \frac{p_y}{p_x}\left|x - \frac{p_x}{\sqrt{p_x^2 + p_y^2}}\right|.$$

For $x > \frac{p_x}{\sqrt{p_x^2 + p_y^2}}$ this is clearly the same as equation $(2)$, and for $x < \frac{p_x}{\sqrt{p_x^2 + p_y^2}}$ the constant terms cancel, so the function value defined here is then the same as the value given by equation $(1)$; and of course when $x = \frac{p_x}{\sqrt{p_x^2 + p_y^2}}$, $y = \frac{p_y}{\sqrt{p_x^2 + p_y^2}}$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.