Shop OBEX P1 Docs P2 Docs Learn Events
Changing Coordinates During Runtime — Parallax Forums

Changing Coordinates During Runtime

idbruceidbruce Posts: 6,197
edited 2012-11-23 06:58 in Propeller 1
Hello Everyone

I have a new challenge that I am attempting to conquer. I want the Propeller chip to figure run time coordinates. Here are the circumstances before any changes:
  • Cartesian Coordinate System
  • All coordinates are in Quadrant I
  • Fixed point of origin (0, 0)
  • A imaginary perimeter surrounds all points.

This is what I want to accomplish:
  • I want to move the point of origin to the center of the perimeter. So instead of just using Quadrant I, all four Quadrants will now be utilized.
  • After a coordinate has been relocated, I want to then convert the Cartesian Coordinate to a Polar Coordinate.
As I see it, relocating the point of origin in respect to a given coordinate, should simply be a matter of subtracting half of the perimeter. I was thinking something along the lines of the following:
  • NewXValue = OldXValue - (PerimeterWidth/2)
  • NewYValue = OldYValue - (PerimeterHeight/2)
  • NewCoordinate = (NewXValue, NewYValue)

After a new coordinate location has been established, it can then be changed to a Polar Coordinate with the following formulas:
  • r = √ ( x2 + y2 ) *Use the Pythagorean Theorem to find the hypotenuse.
  • θ = tan-1 ( y / x ) *Use the Tangent Function to find the angle.

Okay, those are my thoughts. So now, firstly, is my line of thinking correct? And secondly, what do I actually need to do, to be able to perform these mathematical operations on a Propeller chip? Do I need floating point support.... ETC... An example would be helpful. :)

Bruce

Comments

Sign In or Register to comment.