Articles tagged (
geometry
)




Plotting an Arrow using C++
Published 23 Aug 2021

Using FLTK graphics library to draw an arrow.

ebm8tnyxdmf3lfptrnjl.png


Aim - Create a C++ program to draw an arrow:

  • between 2 given coordinates
  • arms of length as a given ratio to its body length
  • arms at specified incline to the body


kicomvydi7rataondhm2.png


Given:

  • Start point of arrow as (x1, y1) and end point (x2, y2). Eg: (2, 3) and (10, 100)
  • Ratio provided = x : y. Eg 1:10
  • Incline of arrow arms (in degrees) = θ. Eg: θ=67


Attempt 1


Attempt 1 relies on individually calculating the slope of all 3 lines and finding points of the arrow by combining equations of distance formula, tangent slope for...

66 views


Star Program C++
Published 21 Jun 2021

Plotting n sided star using Graphical Interface

f3a086baa1cd611befa35b733c0d7cd1.pngStar.cpp


#include "Graph.h"
#include "Star.h"
#include <cmath>
#include <iostream>


const double PI = atan(1) * 4;

namespace Graph_lib {
	Star::Star(Point center, int n, int w, int len) {
		// outer circle
		std::vector<Point> out;
		std::vector<Point> in;


		for (int i = 0; i < n; i++)
			out.push_back({
			  center.x + int(len * cos(float(2 * PI * i) / n)),
			  center.y - int(len * sin(float(2 * PI * i) / n))
			});
		
		for (int i = 0; i < n; i++) {
			const double angle = float(2 * PI * i...
65 views