Calculating dr/dtheta at an arbitrary point and angle

In summary: Theta_T)}{sin(\Theta_T)}s+ r_1sin()\theta_1)\right)}{\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}s+...}\right)}
  • #1
haytil
7
0
In writing a computer raytracing simulation using polar coordinates, I've come across a simple problem: I need to calculate the value of dr/dΘ at an arbitrary point (in polar coordinates), pointing in an arbitrary direction (given as an angle).

So if point 1 (p1) is given by the coordinates (r1, Θ1), and I create a ray from that point, pointing at an angle Θ2 with respect to p1 (not with with respect to the origin), I need to know the value of dr/dΘ along that ray at that starting point.

Of course, Cartesian coordinates is much simpler: dx/dy as a function of Θ2 does not depend on the values of x and y at the point you're trying to calculate from. In polar coordinates, however, given an arbirtrary value Θ2, dr/dΘ will change depending on what the value of r is at the point you're trying to calculate from. Beyond that, however, I do not know the explicit formula that I need. So my current algorithm/equation relies on converting to cartesian coordinates and then doing the calculation.

It is as follows:

-----------------------------------
dx = cos(Θ2)
dy = sin(Θ2)

x1 = r1 * cos(Θ1)
y1 = r1 * sin(Θ1)

(This assumes dx << x1 and dy << y1. If not, dx and dy are divided by a large constant)

rT = sqrt( (x1+dx)^2 + (y1+dy)^2 )
ΘT = arctan( (y1 + dy) / (x1 + dx) )

Add 2pi or pi to thetaT as necessary (depending on which quadrant the point p1 is in)

dr = rT - r1
dΘ = ΘT - Θ1

dr/dΘ = (rT - r1) / (ΘT - Θ1)
-----------------------------------

This algorithm is undesirable both because it is inelegant (in its roundabout way of first converting to cartesian coordinates to do the calculation) and slow to run on the machine (trig functions and square roots, when unnecessary, slow things down a great deal, and I'm having many problems with computer-related precision limits which can likely be avoided with a more straightforward algorithm).

I'm sure there's a much simpler solution, involving only polar coordinates, and I'm frustrated that such a seemingly simple problem is stumping me. Can anyone help out?
 
Last edited:
Physics news on Phys.org
  • #2
I don't understand what you mean by "pointing in some arbitrary direction". If r is a function of [itex]\theta[/itex], then its derivative at any point is a single number, not a vector, and does not "point" in any direction. In order to have a different derivative in different directions, you would have to have a function of at least two variables, say f(r,[itex]\theta[/itex]), not r([itex]\theta[/itex]).
 
  • #3
HallsofIvy said:
I don't understand what you mean by "pointing in some arbitrary direction". If r is a function of [itex]\theta[/itex], then its derivative at any point is a single number, not a vector, and does not "point" in any direction. In order to have a different derivative in different directions, you would have to have a function of at least two variables, say f(r,[itex]\theta[/itex]), not r([itex]\theta[/itex]).

I'm sorry, I'm not being very clear. The scenario I'm trying to handle is quite simple, I'm just not explaining it right. Let me try again:


Imagine a straight line that passes through the point (r1, Θ1) and that the slope of the line at that point is sin(ΘT)/cos(ΘT).

What is the value of dr/dΘ of the line at that point? (In terms of r1, Θ1, and ΘT)
 
  • #4
haytil said:
I'm sorry, I'm not being very clear. The scenario I'm trying to handle is quite simple, I'm just not explaining it right. Let me try again:


Imagine a straight line that passes through the point (r1, Θ1) and that the slope of the line at that point is sin(ΘT)/cos(ΘT).

What is the value of dr/dΘ of the line at that point? (In terms of r1, Θ1, and ΘT)
Your question still doesn't make sense. What is "T"? The slope of a straight line is a constant and so T should not be a variable. Or do you mean [itex]\Theta T[/itex] as "[itex]\Theta_T[/itex], a constant? If that is the case then the line, in xy-coordinates (since the slope of a line is defined in terms of xy- coordinates), is given by
[tex]x= \left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1cos(\theta_1)[/tex]
[tex]y= \left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1sin(\theta_1)[/tex]
and, since [itex]x= r cos(\theta)[/itex], [itex]y= r sin(\theta)[/itex],
[tex]r cos(\theta)= \left(\frac{cos(\Theta_T)}{sin(\Theta_T)}s+ r_1cos(\theta_1)[/tex]
[tex]r sin(\theta)= \left(\frac{cos(\Theta_T)}{sin(\Theta_T)}s+ r_1sin()\theta_1)[/tex]
we have, by squaring and adding,
[tex]r^2= \left(\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1cos(\theta_1)\right)^2+ \left(\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1sin(\theta_1)\right)^2[/tex]
or
[tex]r= \sqrt{\left(\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1cos(\theta_1)\right)^2+ \left(\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}\right)s+ r_1sin(\theta_1)\right)^2}[/tex]
Dividng the second equation by the first
[tex]tan(\theta)= \frac{sin(\theta)}{cos(\theta)}= \frac{\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}s+ r_1sin()\theta_1)\right)}{\left(\frac{cos(\Theta_T)}{sin(\Theta_T)}s+ r_1cos(\theta_1)\right)}[/tex]
 

1. What is the formula for calculating dr/dtheta at an arbitrary point and angle?

The formula for calculating dr/dtheta at an arbitrary point and angle is:
dr/dtheta = (dx/dtheta * dy/dx) - (dy/dtheta * dx/dx)

2. How do I find the values of dx/dtheta and dy/dtheta for a given point and angle?

To find the values of dx/dtheta and dy/dtheta for a given point and angle, you can use the chain rule. First, find the derivative of x and y with respect to theta. Then, substitute the values of x and y at the given point and angle into the derivatives to find the values of dx/dtheta and dy/dtheta.

3. Can I use the same formula for any type of curve?

Yes, the formula for calculating dr/dtheta at an arbitrary point and angle can be used for any type of curve, as long as the curve is defined in terms of x and y as functions of theta.

4. What is the purpose of calculating dr/dtheta at an arbitrary point and angle?

The purpose of calculating dr/dtheta at an arbitrary point and angle is to determine the rate of change of the distance from the point to the curve with respect to the angle. This can be useful in analyzing the behavior of a curve and understanding its properties.

5. Are there any practical applications of calculating dr/dtheta at an arbitrary point and angle?

Yes, there are many practical applications of calculating dr/dtheta at an arbitrary point and angle. For example, it can be used in engineering and physics to analyze the motion of particles on a curved path, in navigation to determine the direction and speed of movement, and in computer graphics to create smooth and accurate animations of curves and surfaces.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
7
Views
823
Replies
3
Views
1K
  • Special and General Relativity
Replies
11
Views
1K
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
3
Views
116
Replies
9
Views
1K
  • General Math
Replies
3
Views
1K
  • Precalculus Mathematics Homework Help
Replies
20
Views
2K
Replies
1
Views
2K
Replies
1
Views
525
Back
Top