Trig Help: Measuring Length & Coordinates on a Unit Square Grid

  • Thread starter Thread starter JazzMasterKC
  • Start date Start date
  • Tags Tags
    Square Trig Unit
Click For Summary
SUMMARY

This discussion focuses on calculating the distance from the center of a 2x2 unit square grid to points on its perimeter based on a given angle. The user seeks to create a single function to determine this distance for angles ranging from 0 to 360 degrees, rather than using multiple functions for different angle ranges. The solution involves using the secant function, expressed as 1/cos(q), where q is the angle between 0 and 45 degrees, and applying modulus and floor functions to manage angle transitions effectively. The proposed formula is sec[{(1-2*floor[(x%90)/45])*x}%90], which simplifies the calculations significantly.

PREREQUISITES
  • Understanding of trigonometric functions, specifically sine and secant.
  • Familiarity with angle measurement in degrees.
  • Knowledge of modulus and floor functions in programming.
  • Basic concepts of coordinate geometry and unit squares.
NEXT STEPS
  • Research the properties of the secant function and its applications in geometry.
  • Learn about implementing trigonometric functions in programming languages like Python or JavaScript.
  • Explore graphical representations of trigonometric functions to visualize angle transitions.
  • Study optimization techniques for mathematical functions in programming to enhance performance.
USEFUL FOR

Mathematicians, computer programmers, and students studying trigonometry or geometry, particularly those interested in optimizing calculations for graphical applications or simulations.

JazzMasterKC
Messages
19
Reaction score
0
0. The app does not have the template built in so ill do my best, sorry i don't have a computer right now.

1. This is a personal project, and there is a lot to it but I'm cutting out down to where i need help.

Imagine a 2x2 grid of squares (2d for now). The center vector is at (0,0), and the length of one side of a square is 1m (or just think of one, distance doesn't matter right now). So essentially the grid is 2m by 2m. Now a arrow/line is abstract so it can help us meassure the distance from the center to a point on the outer rim of the grid.. in otherwords think of this like the unit circle (trig) but in a square... This is actually the direction where an object will be projected but that's unrelated to my question.

2. So what i wanted was to obtain that length of arrow/line and actually the cordinates on the grid.. i can figure that out easily because I am given the angle of the arrow.. and yes so if the arrow is at the cordinate (0,1) that is a 90 degree angle. I can use a triangle for reference but since its a square i can't seem to figure out how to write a function that can pull this off from 0 degrees to 360.. every 45 degrees i have to switch which function it will use.. and I been using the tool of sin(A)/a=sin(B)/b.. as well as soh-cah-toa because i use the right angle to help me find the distance of the arrow.

3. So my question is how can i make this into one function rather then 8 different ones that switch after x amount of degrees. This is also a computer program so id like to keep it optimal.. my math course is entering calc 1 this fall so pre-calc.. I wonder if I'm not seeing something or is there other tools avaliable to help me figure this out?

Thanks
 
Physics news on Phys.org
This should return the length for any angle:

sec[{(1-2*floor[(x%90)/45])*x}%90],

where x is your angle in degrees, % is the modulus function, floor returns the next lowest integer, and sec is the secant function.

I would have a hard time explaining this without drawing a picture, but here goes... The distance to the edge of the unit square can always be expressed as 1/cos(q)=sec(q), where q is an angle between 0 and 45. This value should rise from 0-45 as x goes from 0-45, fall from 45-0 as x goes from 45-90, and so on. Can you see this? A picture would help. Anyway, the expression (1-2*floor[(x%90)/45]) is equal to 1 when x is from 0-45, 90-135, etc. and equal to -1 when x is from 45-90, 135-180, etc. Then {(1-2*floor[(x%90)/45])*x}%90 ends up creating the required graph for q.
 
Last edited:
Wow good idea thanks a lot!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K