Question 486485: I have a line-segment on the Cartesian Plane. I know the endpoints by their distance from the origin and the angle from the x-axis.
To make it all simple, assume one point is on the x-axis.
I'll call the difference between these two angles the "angular-spread", for lack of a better education.
I need to know how to calculate a point on the line-segment given an angle that lies between these two points.
I've been trying to deduce the answer to this problem by graphing it in real time and analyzing the result. I've come up with some equations that sort-of work, but none work for every line, and I must guess at the factors involved for each line and fine tune it until I get an acceptable result. Not a workable solution. I was hoping at least I could begin to see the pattern and then be able to automatically calculate the factor. For five months my brain has been frustrated with this problem.
A simplified version of this problem is how to calculate the radial distance from the origin to the edge of a regular polygon inscribed within a circle centered at the origin, given an angle. The line segments do not “slope” in this problem. Assume one point of the polygon lies on the x-axis. (and I'll just call it a polygon henceforth, but I mean regular polygon)
Every way I address this issue, the line comes out curved.
At first I attempted to use the properties of tan and arctan to address this problem. This also allowed me to control the shape of the line to some extent without leading to illogical answers - I could plug in any positive number.
I then looked at it in a different way, and attempted to use the half-chord formula ( where a is the angular spread of the chord) to calculate the "in-radius" (I learned that term from your website: thanks!) and hence the difference between the radius and in-radius. Then by converting the angle of the point in question on the line to a ratio (angle = angle / angular-spread) I could try to calculate the difference via a sin curve. Once the distance from the origin is found, the point can be calculated from the known angle and calculated distance. Anyway, it's really the distance from the origin I ultimately want to know.
Here's that formula:
d? = the distance from the origin to the point in question.
a = the known (given) angle of the point in question.
s = the known "angular-spread".
r = the known radius of the circle that contains the polygon; i.e. the distance from the origin to any and every corner of the polygon.
Things get more complicated when the line segment has ends that are not equidistant from the origin. The Angle that bisects the "angular-spread" no longer bisects the line segment, but perhaps that ultimately doesn't mater - it correctly factors for the "slope" (I'm using slope in a metaphorical way - I suppose it's a slope on the polar grid...).
Here are more formulas I've tried that attempt to define any line inscribed in a circle by a given angle, a given "factor" (any positive number, but must be fine tuned "by hand"), and known endpoints based on their angle and distance from the origin:
d? = the distance from the origin to the point in question.
a = the known (given) angle of the point in question.
s = the known "angular-spread".
f = the given factor
r1 = the distance from the origin to the first point
r2 = the distance from the origin to the second point
I'm working on an open source (free for all to use and or modify) software project for creating graphics using modern image formats (.png alpha transparency) in ways that are not supported by most other graphic design programs. I'm writing it in the PHP language, which is fairly simple to read by even a non-programmer to some extent. Mathematical formulas are understandable, I think.
Use Open Office draw to create a star, and fill that star with a "radial gradient" and you get a circular radial gradient that shows through a star-shaped mask. I want a star-shaped gradient! The same goes for any other shape.
I've got a working solution that not only does this, but allows you to create multi-colored gradients with multiple transparency gradients. It does circles, ellipses, stars (using the formulas above – note how these formulas allow me to “swell” the sides out, or pull them inwards, an effect I want), polygons (using the one formula above), and others not easily described here. It just doesn't do perfectly strait edges...yet
It can even take your basic shapes and place them repetitively in a ring on the polar grid. That makes some really cool effects. I could go on and on about how this software is great, but it is NOT a replacement for other desktop image creation software, and will never be sell-able in that respect. PHP is far too slow.
If you're curious, you can see the central color-highlighted code (easy to read when highlighted by color) here:
http://softmoon-webware.com/rainbow-maker/Rainbow.htm
You can get the entire software package here (but you will need a working server with PHP, at least until PHP becomes a stand-alone package that works with browsers - i.e. it's own server - that you can install on your system.)
http://softmoon-webware.com/rainbow-maker/rainbow-maker.7z
You can get an simple-to-install server package with Apache and PHP (and more) using XAMPP from the Friends of Apache:
http://www.apachefriends.org/en/xampp.html
Then you can use this as a desktop application using your browser.
A working example is also found at:
http://softmoon-webware.com/rainbow-maker/
But this will limit the size of the graphic created, because it's on a public server.
I took trig in college over 20 years ago – thanks to Wikipedia, I came up with this much so far. PLEASE help me finish it (if only so my brain will stop throbbing). All I need is a basic formula...
Aloha!
Answer by richard1234(7193) (Show Source):
You can put this solution on YOUR website! You are making this a bit too complicated. This is a tricky problem, but I believe it can be solved using elementary algebra and geometry.
We can let AC = kAB, and CB = (1-k)AB.
Suppose we use Stewart's theorem:
(upon expanding)
(gathering all k terms to LHS, everything else to RHS).
We can cancel out AB on both sides to yield
This becomes a quadratic in terms of k,
Every variable is a constant, except OC. To deal with this, we use the law of cosines:
We can find cos(OAC) because this is equal to cos(OAB), which we can also use the law of cosines. I'll let you finish off from here; simply find cos(AOB), replace it into your expression for OC^2, then replace OC^2 and you should (hopefully) obtain a quadratic in terms of k where all the coefficients are constants. Then you can find k and the coordinates of C. It will be tedious, but sometimes the process of finding the solution is more important than the solution itself. Given that, try finding a solution using vectors or complex numbers, you might find something completely different...(and/or easier). The hardest part is trying to reduce everything into a one-variable equation because OC, AC, BC and angles AOC, COB are all variable.
|
|
|