Monday, April 1, 2019

Sine, Cosine, Tangent


Definition

  • Opposite is the opposite line to the angle θ.
  • Adjacent is the adjacent line to the angle θ.
  • Tangent is the opposite line to the right angle.
  • The triangle must be a right triangle (also known as "right-angled triangle").
Sine, Cosine, Tangent are defined as






Calculation

When the following triangle is given,

Sine, Cosine, Tangent are calculated as 



Ratio

When θ is 30°, the ratio of the lengths of the lines are:
Opposite : Adjacent : Hypotenuse = 1 : √3 : 2
When θ is 45°, the ratio of the lengths of the lines are:
Opposite : Adjacent : Hypotenuse = 1 : 1 : √2


Transration

Sine, Cosine, Tangent can be translated to each other:

Or


Or


Or


Law of sines

Law of sines:
image is from wikipedia "Law of sines"



where a, b, and c are the lengths of the sides of a triangle, and A, B, and C are the opposite angles. R is the radius of the triangle's circumcircle. 

Law of cosines

Law of cosines:
image is from wikipedia "Law of cosines"



where γ denotes the angle contained between sides of lengths a and b and opposite the side of length c.

For the same figure, the other two relations are analogous:


Law of tangents

Law of tangents:
image is from wikipedia "Law of tangent"



where a, b, and c are the lengths of the three sides of the triangle, and α, β, and γ are the angles opposite those three respective sides.

Trigonometric Addition Formulas




Calculation example








Value of sin, cos and tan
image is from quora




References

Wikipedia, "Law of sines", 2019 July 20th visited
Wikipedia, "Law of cosines", 2019 July 20th visited
Wikipedia, "Law of tangents", 2019 July 20th visited
Math is fun "Sine, Cosine and Tangent", 2019 July 20th visited

Manipulations of int and String in Java

At first, declare a variable as int:
int n = {your number};
To remove a right most digit:
n = n / 10;
To check if right most digit is 8:
n % 10 == 8;
If we declare a String variable:
String str = "Hello, test here.";
The last character of the String can be gotten like this:
String lastChar = str.substring(str.length() - 1);
To remove the last character of the String:
String str = str.substring(0, str.length() - 1);
Get number of characters of the String:
int numOfChars = str.length();

Weird behaviors

This returns 1:
public int returnOne() {
  return 1;
}
But this returns 0. This looks like it would return 1 though..
public int returnOne() {
  int count = 0;
  return count++;
}
But this returns 1.
public int returnOne() {
  int count = 0;
  return ++count;
}