C++ :: Draw A Crescent Moon Shape And Extracted Values To Excel To Be Drawn
Mar 28, 2013
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.
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.
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.
I just got a job programming a windows application. One of the requirements is reading and writing values from an excel spreadsheet. Looking online, it appears that C++ isn't the best (one of the worst?) languages for reading and writing values from excel files. Now the language I'm most familiar with is C++ and I've been looking at C#, and it appears to be much easier to read excel files.
Now I can fatch all the excel sheet belongs to the Excel File.But How can I check "If and Only If the sheets are havin Underscore in their name(eg. student_data,teachers_data) then only the data of the sheets will populate in tha data base"
I have an emulation project I've been working for a long time (the Altair32 Altair/IMSAI emulator) and I'm trying to simulate a dot-matrix printer for list output in CP/M.
Here's what I have so far and where I'm stuck and need a push in the right direction. I'm using a dialog box with a green bar paper bitmap as the client area background. I used CreateFont to load a dot matrix printer TrueType font and have the base code to print on subsequent lines. So, based on the dialog size, font size, etc., I get about 10 lines of dot matrix printing, 80-characters wide. So far so good.
The problem arises in how do I scroll the text like on a printer? I thought about trying a static text control or an edit box, but the text to be printed is of an unknown size and ISTR that both of those controls have finite size limits (32k but maybe I'm wrong). They would also need to be transparent so that the green bar paper shows through.
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 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.
dynamically allocated arrays. int (*ttt)[2][10]; If I'm not mistaken this declares a pointer (that's all). This pointer has an intrinsic shape that makes it easier to access row, column without doing my own math to calculate the offset.
ttt = malloc(2 * 10 * sizeof(int));
So I should be able to access elements like this: ttt[i][j].
ttt[i][j] = 123;
But the compiler says: error C2440: '=' : cannot convert from 'int' to 'int [10]'...how to go about accessing a monolithic block of allocated memory using 2 or more dimensions, using some sort of casting to a known shaped array if possible. As opposed to doing i * cols + j type stuff.
And for some reason my program pauses (nothing displays, and my cursor changes to the little "loading" cursor thingy) when it hits line 139. That is where I added an additional piece of code that should change the shape of the triangle while the program is running.
Having issues with program to create a shape area calculator with circle square and rectangle. the uml goes as follows:
Where the UML has shape as the abstract class with public area():double, getName():string,and getDimensions:string, rectangle derived from shape with protected height, and width, and a public rectangle(h:double, w:double), followed by a derived square from rectangle with just a public square(h:double), and finally a circle derived from shape with a private radius, and a public circle(r:double).
[URL]
Have linked my program and it is giving me the following compiler errors:
error: 'qdebug' was not declared in this scope line 15 of main
error: cannot declare variable 'shp' to be of abstract type 'shape' line 22 of main
error: expected primary-expression before ')' token lines 29 -31 of main
(note previously had qstring as a header file yet changed to string since I was getting error qstring was not declared in this scope.)
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?
Write a program to ask a user to input a symbol from the keyboard and to output that symbol in a n X n/2 sized V where n = the width of the V. You must use a loop to process the data
I am stuck at trying to figure out how to do the actual output formatting. This is where I am sitting currently.
string character = ""; int vheight = 0; Console.WriteLine("Enter the character you wish to use for your V: ");
[Code]....
so Im really just a bit stumped on how to get the actual V shape to be formatted..
I am fairly new to c++, and I want to be able to draw a polygon. When I have searched for how to draw one, the only thing i can find is scripts doing things like this:
* ** *** **** *****
I doubt that c++ is that primitive, and I'm looking for something like the c++ equivalent of this python script:
I have to compare data in excel and csv based on the file name and update the status of file from CSV into excel file by creating a new column status on weekly basis.
Is it possible to create an app that can be saved on my desktop that can be used with an excel file that is saved on my desktop? I have opened VS 2010 and I have created a form design that has a button for every sheet name in my excel file. All of the sheet names are hidden with the exception of one. When a button is pressed on the c# form, I would like for that sheet to be shown in excel. Then once the updates have been made to that sheet in excel, I want a button to be at the top of the excel worksheet that will hide that worksheet again and return to the form c# form...can that be done?
I'm trying to create a grid using the following characters: !, @, #, $, &.
It's an 8 x 8 grid, and should contain the characters in no particular order (trying to create a Bejeweled-like game).
I already defined the width and length to be 8, so:
#define WIDTH 8 #define LENGTH 8
Code:
void makegrid(char grid[]) { int j; int k; for ( j = -1; j < LENGTH; j++ ) { for ( k = -1; k < WIDTH; k++ ) { /* I don't know what to type here anymore :( */ } } }