Check whether a given point lies inside a triangle or notGiven three corner points of a triangle, and one more point P. Write a function to check whether P lies within the triangle or not. Example: Input: A = (0, 0), B = (10, 30), C = (20, 0), P(10, 15)Output: InsideExplanation: B(10,30) / \ / \ / \ / P \ P' / \ A(0,0) ----------- C(20,0) Input: A = (0, 0
15+ min read
Program to find area of a triangleGiven the sides of a triangle, the task is to find the area of this triangle. Examples : Input : a = 5, b = 7, c = 8 Output : Area of a triangle is 17.320508 Input : a = 3, b = 4, c = 5 Output : Area of a triangle is 6.000000Recommended PracticeArea of a triangleTry It! Approach: The area of a trian
10 min read
Count Integral points inside a TriangleGiven three non-collinear integral points in XY plane, find the number of integral points inside the triangle formed by the three points. (A point in XY plane is said to be integral/lattice point if both its co-ordinates are integral). Example: Input: p = (0, 0), q = (0, 5) and r = (5,0) Output: 6Ex
8 min read
Find all angles of a given triangleGiven coordinates of all three vertices of the triangle in the 2D plane, the task is to find all three angles.Example: Input : A = (0, 0), B = (0, 1), C = (1, 0) Output : 90, 45, 45 To solve this problem we use below Law of cosines. c^2 = a^2 + b^2 - 2(a)(b)(cos beta) After re-arranging beta = acos(
7 min read