0
$\begingroup$

I can't find the definition of a function $f(x); x \in [-1;1]$ where $(x|f(x))$ is a point on the unit-circle.

Can you please give me a hint?

---------- Edit -----------

Background:

I want to render a filled circle (programatically) onto a screen using an iteration from $x-rad \rightarrow x+rad$ where $x$ is the x-position of the circle on the screen, and $rad$ is the radius.

Solution:

$f(x) = cos(sin^{-1}(x))$

seems to work pretty well. For the programmers under us, here is Python-code to demonstrate my approach:

import math  def drawCircle(xpos, ypos, radius):     for x in xrange(radius * 2):         x = x - radius          ytop = math.cos(math.asin( x / radius ))         ybot = -ytop          x = x + xpos         drawLine( x, ypos+ytop, x, ypos+ybot) 

Result:

image of an orange circle rendered using python

  • 0
    What does $(x|f(x))$ mean? Did you intend that to be $(x,f(x))$ a co-ordinate on the unit circle?2012-01-23
  • 0
    Draw the unit circle on a piece of paper, pick a point on it, consider its projections on the axes, and apply Pythagoras' rule.2012-01-23
  • 0
    Do you know of *any* functions that map to the unit circle? You knew enough to tag this "trigonometry", so it should come as no surprise if trig ratios come into play.2012-01-23
  • 0
    @Emre Oh man, simpler than I thought. Headache, you know? ;-) $f(x) = cos(sin(x))$ ?2012-01-23
  • 0
    If we have to work in the reals, then $f(x)$ will be an ordered pair. Does $(\cos x,\sin x)$ work? Not quite, we only travel over part of the circle. But what about $f(x)=(\cos(\pi x),\sin (\pi x))$? If we are allowed to use complex numbers, there is the more elegant $f(x)=\cos (\pi x)+i\sin (\pi x)$. We need to say $-1, else one point will be reached twice.2012-01-23
  • 1
    Sorry, mistyped. I meant $f(x) = cos(sin^{-1}(x))$ which actually seems to work well.2012-01-23
  • 0
    @André, it seems that the function need not be onto, so maybe a "simple" $f : [ -1, 1] \to \mathbb_{R}$ would suffice... ? Hmm... seems I have lost my Latex touch.2012-01-23
  • 0
    @Niklas R: If you mean that $(x, f(x))$ roams over the unit circle, then $\cos(\arcsin x)$ doesn't quite work, since the cosine of angles between $-\pi/2$ and $\pi/2$ is non-negative, so we only get half the circle.2012-01-23
  • 0
    Begin by writing down a relatiionship between $x$ and $y$ that holds if $(x,y)$ in on the unit circle.2012-01-23
  • 0
    @AndréNicolas I didn't say, I wanted the function to replicate the whole unit-circle, the resulting point just needs to lie on it. Maybe my *edit* makes it more clear. Thanks to everyone who offered his help.2012-01-23

1 Answers 1

2

For $-1\le x\le 1$, $$\cos(\sin^{-1}x)=\sqrt{1-x^2}.$$

A circle with radius $r$, centered at the origin can be described by $$x^2+y^2=r^2.$$ Solving for $y$ in terms of $x$ gives $$y=\pm\sqrt{r^2-x^2}.$$

  • 0
    Definately a nicer than using $cos$ and $sin$. I sure wouldn't have come to this equation. Thank you!2012-01-23