Visual C++ :: Crescent Moon - Calculate Points On This Shape
Mar 28, 2013
My question is, I have been tasked to draw this shape,
![Crescent Moon][URL] ....
This is to be done using C++ to write code that will calculate the points on this shape.
Important details.
User Input - Centre Point (X, Y), number of points to be shown, Font Size (influences radius)
Output - List of co-ordinates on the shape.
The overall aim once I have the points is to put them into a graph on Excel and it will hopefully draw it for me, at the user inputted size!
I know that the maximum Radius is 165mm and the minimum is 35mm. I have decided that my base [Font Size][1] shall be 20. I then did some thinking and came up with the equation.
Radius = (Chosen Font Size/20)*130. This is just an estimation, I realise it probably not right, but I thought it could work at least as a template.
I then decided that I should create two different circles, with two different centre points, then link them together to create the shape. I thought that the INSIDE line will have to have a larger Radius and a centre point further along the X-Axis (Y staying constant), as then it could cut into the outside line.*
*(I know this is not what it looks like on the picture, just my chain of thought as it will still give the same shape)
So I defined 2nd Centre point as (X+4, Y). (Again, just estimation, thought it doesn't really matter how far apart they are).
I then decided Radius 2 = (Chosen Font Size/20)*165 (max radius)
So, I have my 2 Radii, and two centre points.
This is my code so far (it works, and everything is declared/inputted above)
for(int i=0; i<=n; i++) //output displayed to user {
Xnew = -i*(Y+R1)/n; //calculate x coordinate
Ynew = pow((((Y+R1)*(Y+R1)) - (Xnew*Xnew)), 0.5); //calculate y coordinate
[Code] ....
I am having the problem drawing the crescent moon that I cannot get the two circles to have the same starting point?
I have managed to get the results to Excel. Everything in that regard works. But when i plot the points on a graph on Excel, they do not have the same starting points. Its essentially just two half circles, one smaller than the other (Stops at the Y axis, giving the half doughnut shape).
If this makes sense, I am trying to get two parts of circles to draw the shape as such that they have the same start and end points. Currently all I am getting more a 'half doughnut' shape, due to the circles not being connected.
I have some code that will allow me to draw a crescent moon shape, and have extracted the values to excel to be drawn. However in place of some numbers, there is '-1.#IND' in place.
I'm creating a quick program to calculate midpoint and distance between two points. I'm having a little trouble. This is the program:
//This program is a start to solve basic coordinatre plane distances and midpoints #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; int main(int nNumberofArgs, char* pszArgs[]){ cout << "This is a calculator to find distance and the midpoint between two points. " ;
[Code]...
the problem is that the output for both equations is wrong, it doesn't do the math properly and I assume it has to do with the variable types I'm using but am not sure. P.S. I am using the latest version of DEV-C++
In my project i need to calculate the distance between two lattitude and longitude points. After compiling the code I am getting an error that "conflicting types for deg2rad". How to solve this? Seems the code looks ok. but...
I know how to define a shape (here, a rectangle) and attach it to a window in C++ as follows:
Code: #include <Simple_window.h> void cir() { Circle c(Point(100,100),50); } int main() { Simple_window win(Point(100,100),600,400, "test");
[Code] ....
But how to define a shape (say a circle by that cir() function which is) outside of the main() function that is how to create a circle inside of the cir() function and it returns that circle when I called it in my main() function so that I can attach it on the window win to be visible?
When I remove the BeginPath() and EndPath() functions my lines are being drawn. But when I insert this BeginPath() and EndPath() and StrokeAndFillPath(hDC); the nothing is being drawn.
Why it is not doing as per the expectations. I want to draw a shape for example A with a outline. And i want it to be closed when drawing is ended and filled the hollow portion.
What am I doing wrong in this ?I am not implementing it in WM_PAINT but drawing is done in WM_LBUTTONUP.
So I'm currently using Visual Studio 2013, and I was left for homework as a beginner programmer to calculate two summations. First the summation of k to n. k=1 and the equation being k^3. The parameter would be n and I need to printf the results for n=5, 33, 100, 442, 3456.
I know that some of the numbers are big values so float or long should be used but how to define these as of yet.
Another is to find the summation (n) (k) <<-- one big paranthesis
for values k=8 and n=10, 21, 35, 46, 68
How to start excluding <stdio.h> and int main ... Also, do I have to repeat a new function for every number for n?!
This is what I have so far for something I did differently
// Factoriales Sumatorias
#include <stdio.h> int suma1 { int n = 5; // Defino e Inicializo la variable long sumatoria = 1; // definicion e inicializacion del resultado while (n <= 5)
I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly.
Code: #include <iostream> #include <iomanip> #include <string> #include <fstream> #include <cmath> using namespace std; int main () { cout << " This program will produce statistics (Mean, Standard Deviation, "
Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.
So if i write a Loop to calculate Prime Numbers in order, is there any way possible for this to happen in a shorter period of time.
The loop that i constructed took about 11hrs on a Win 7 2GB ram machine to calculate about 150,000 primes, could this be done any faster................
I have begun switching from WinForms to WPF and I'm having a hard time understanding the new concepts. In WinForms, I had a few User Controls, custom drawn using shapes (rectangles, ellipses, etc). They had some unique properties, like "Flashing" (setting this property to True and setting the "Flash Interval" property to 500 would have resulted in the control changing its background color to white and back again, every 0.5 seconds), "Beeping", etc.
I have tried to replicate these controls in WPF/XAML and so far managed to draw the shape. However, when it came to implementing a custom property that would redraw the background color of the rectangle every interval set by user in another property, i got stuck. The property is being set, but it doesn't change the background color. Alternatively, i have tried this method, with the same results (i got it to show in the "Properties" window in Visual Studio, i can set it, it is being stored in XAML, but it doesn't affect the background.
C# code behind: public struct LCARSColors { public static Brush DarkBlue = (Brush)(new BrushConverter().ConvertFrom("#FF3366CC")); public static Brush LightBlue = (Brush)(new BrushConverter().ConvertFrom("#FF99CCFF")); public static Brush Pink = (Brush)(new BrushConverter().ConvertFrom("#FFCC99CC"));
[Code] ....
If i use this line (commented in this code sample):
I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.
I'm doing a project and I need to draw a square into a pgm image if certain conditions are met, but I'm not sure how to draw the square into the image.
I'm building a pretty basic calculator program that calculates the area of generic shapes (triangles, rectangles, and squares); for some reason though, my program is having troubles as soon as it hits the if/else code in the int main section. When I enter triangle, rectangle, or square, it just spits back out the "That's not one of the options. Please re-enter and try again." error line I created. When I isolate and run just the stuff inside the if/else statements it works great, but why it won't just understand my if (shape == triangle).... .
Code:
#include <iostream> using namespace std; class figure { protected: double x, y;
But how to define a shape (say a circle by that cir() function which is) outside of the main() function? And how to attach it to be visible on window win?
have a problem with my code (I wish for answer with code). The conditions I have to grant:
- **Only** a pointer to an object must be saved in a **standard** class vector (e.g vector<ShapePtr>) - Base class must be a polymorphic class (I call this class ShapePtr) - I **must** have a deep copy process - Constructor is **not** suppose to do a deep copy - **clone()** is suppose to do the deep copy
Here is the code **provided** to me:
main.cpp int main() { typedef shared_ptr<Shape> ShapePtr; vector<ShapePtr> shapevec;
I know how to define a shape (here, a rectangle) and attach it to a window in C++ as follows:
#include <Simple_window.h> void cir() { Circle c(Point(100,100),50); } int main() { Simple_window win(Point(100,100),600,400, "test"); Rectangle r(Point(100,100),Point(300,200)); win.attach(r); win.wait_for_botton(); }
But how to define a shape (say a circle by that cir() function which is) outside of the main() function? And how to attach it on the window win to be visible?
I have cross sections in the form of rectangles in the XY plane formed from two point (top left, bottom right) as well as their Z position. I'd like finding some sort of API that can extrude a basic linear-average-approximated 3D shape (preferably eventually into STL format) from these points. I've tried googling but to no avail. The aim is to build a 3D shape from 2D wireframes.