Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I've been working on this for the past few hours and am quite stuck!

As part of a computer vision exercise I've build a Hough transform that maps between the (x,y) space of an image, and a parameter space (theta,radius). Each point in this (theta,radius) space maps to a single line in (x,y) according to the formula:

$$ r = x \sin{\theta} + y\cos\theta $$

Geometrically, this is explained in this image where the line segment is in red.

The transform is working correctly in one directly. However I'm now looking at a type of probabilistic Hough transform in which I select two candidate points from the x/y space, draw a line through them and and determine the coordinate in (theta,radius) space that corresponds to this line.

Essentially this is solving the two equations with two unknowns (theta,radius):

$$ r = x_1 \sin{\theta} + y_1 \cos\theta $$ $$ r = x_2 \sin{\theta} + y_2 \cos\theta $$

I've been trying, unsuccessfully, to solve this geometrically, but I think an equation should be easier to reason about. However my mathematical ability isn't up to the task of solving these equations. I set them equal to each other, leaving one unknown (theta) but wasn't able to get the two instances out to one side of the equation.

The goal is to process video on a robot with limited computing resource, so efficiency is also important.

Can anyone please point me in the right direction?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

$$x_1 \sin\theta + y_1 \cos\theta = x_2 \sin\theta + y_2 \cos\theta$$

$$(x_1 - x_2) \sin \theta = (y_2-y_1) \cos \theta$$

Divide over $$(x_1 - x_2)\cos \theta$$

You'll get

$$\tan \theta = (y_2 - y_1)/(x_1 - x_2)$$

Get the tan inverse to know $\theta$, then given $\theta$ solve for the following equation to know $r$ $$r = x_1 \sin \theta + y_1 \cos \theta$$

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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