C++ :: How To Find Each Pixel In The Circle

Jul 26, 2014

How can I find each and every pixel in a circle so that I can do some operations on it.

View 6 Replies


ADVERTISEMENT

C/C++ :: Find Angle And Radius Of Given Point Of A Circle

Oct 7, 2013

Let (x,y) be the center of the circle. (x,y) will not be (0,0). I have radius of the circle. Now i want to find the angle and radius of the given point inside the circle.

View 2 Replies View Related

C++ :: Moving In A Circle

Apr 15, 2014

I'm making this program to mess with people and make them think its a virus.

#define _WIN32_WINNT 0x0500 //For hiding your console
#include <cstdlib>
#include <iostream>
#include <Windows.h>
#include <WinBase.h>

[Code]....

At line 42 and 43 I want to make the cursor move around in a circle over and over again but I'm not sure how.

View 4 Replies View Related

C++ :: Calculate Area Of Circle Without Pi

Mar 22, 2013

I was given an assignment for class to calculate the area of a circle using only the radius as a user input and not using Pi in the code. I need to do this by calculating the areas of a series of rectangles under the curve and adding them together. Using nested loops to continuously reduce the size of these rectangles until the approximated area value is within a margin of error less than 0.1%.

Code:
#include<iostream>
#include<cmath>
using namespace std;
int main ()

[Code] .....

View 7 Replies View Related

C :: Printing A Circle In PPM Image

Oct 30, 2013

I'm supposed to print a small rectangle inside concentric circles that are inscribed in a rectangle.I'm not really sure where to start with printing a circle in a ppm file.

View 13 Replies View Related

C++ :: MFC Drawing Circle Instead Of Square

Mar 11, 2014

Found a good beginner's tutorial to learn Visual C++: [URL] ....

How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.

The drawing code from the tutorial is below. How to substitute filled circles for filled squares.

Code:

// CSameGameView drawing
void CSameGameView::OnDraw(CDC* pDC){
// First get a pointer to the document
CSameGameDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(!pDoc)

[Code] ....

View 6 Replies View Related

C++ :: Calculate Dimensions Of A Circle?

Jul 3, 2013

Code:

#ifndef CIRCLE_H
#define CIRCLE_H
class Circle {
public:
//constructors
Circle();
Circle(double r);

[code]....

The function isBigger() returns true (or false) if the radius of the Circle instance on which the function is invoked is bigger (or smaller) than the radius of the Circle instance passed to the function.: How to implement this function?

View 5 Replies View Related

C++ :: White Pixel Value Different From 255

Mar 12, 2014

I am working on image processing in C + + and opencv, I treat images in grayscale, ie the pixel values ​​it must be between 0 (black) to 255 (white).

Mat img; img = imread (file, -1);
for ( int i = 0; i < img. rows ; i ++) {
for ( int j = 0; j < img. cols ; j ++) {
val_pixel=img.at < double >(i,j);
printf( "%d ",val_pixel);
}
printf( "
");
}

when displaying the pixel value from two loop, I get values ​​to 0 and it is normal for propablement black areas, but for whites I find the value -2147483648. I don't understand why this value is not 255.Is there an explanation for this has value.

View 4 Replies View Related

C++ :: SDL2 - Getting Pixel Value

Nov 5, 2013

I use SDL2. and i was testing some functions i took from some internet and some unwanted results happened.

Code :

Pixel *GetPixel(SDL_Surface *surface, int x, int y) {
Uint8 p8, *buf8;
Uint16 p16, *buf16;
Uint32 p32, *buf32;
switch(surface->format->BitsPerPixel {

[Code] .....

And the output changes time to time.

View 3 Replies View Related

C/C++ :: Get Dimension Of Pixel In Mm?

Apr 17, 2012

I have an image of size 640x480 pixels. It's possible to obtain the dimension in mm of one pixel from that image given only that size?I do not have the size of the image in mm,however.

View 5 Replies View Related

C++ :: Creating Array Of Eight Circle Objects

Nov 4, 2013

Im supposed to create an to array of eight Circle objects initialized with the following radii: 2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 3.5, 2.0. Then use a bubble sort to arrange the objects in ascending order of radius size before displaying the area of each object.

The error I get is "Cannot open include file: 'Circle.h': No such file or directory". Do I have to create a separate file for it?

#include <iostream>
#include <iomanip>
#include "Circle.h"
using namespace std;
class Circle {
public:
Circle()

[Code] ...

View 1 Replies View Related

C++ :: Circle Fill Color In - FLTK

Aug 28, 2014

I installed FLTK 1.3.X (from here [URL] ...) on my visual studio 2012 compiler and use PPP book for programming (this: [URL] ..... ). My problem is about filling a Shape in. For example , this code:

#include <Simple_window.h>
using namespace Graph_lib;
int main() {
Simple_window win(Point(100,100), 1000, 600, "Binary_tree");
Graph_lib::Circle c(Point(200,200),50);
c.set_color(Color::red);

[Code] ....

When I run the program, All three Shapes are drawn but only the Rectangle is filled in! Why?

set_color works for the three and apparently the set_fill_color is defined for all Shapes and it too should work but why it doesn't work for Circle and Ellipse?

This is the .CPP and .h files [URL] ....

View 3 Replies View Related

C/C++ :: How To Draw Rectangle Inside A Circle

Jul 5, 2013

Write a program using turbo c to draw a rectangle inside a circle..........

View 2 Replies View Related

Visual C++ :: Radius And Centre Of Circle

Jan 22, 2014

I am drawing a circle using ellipse because there is no explicit command for this.

Code:
pDC->Ellipse(CRect(70, 170, 300, 400));

What is the centre of circle and what is radius in the above command?

View 2 Replies View Related

C++ :: Getting Pixel Information From Fonts?

Mar 27, 2013

How can I import a font file and get the pixel information of the letters so I can make my own custom text drawing function?

I basically have a pixel surface (a 2D array) and I want to draw the text to that array.

View 1 Replies View Related

C++ :: Rotating Pixel Field

Apr 21, 2014

I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.

paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.

angle_step = timestep * angle
// x
ppdPoint[i]->x =
pRotationPoint->x + cos(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) - sin(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);
// y
ppdPoint[i]->y =
pRotationPoint->y + sin(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) + cos(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);

rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:

FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):

while(pBuild->getExecuteFlag())
{
pBuild->draw();
pBuild->update(time_dif, pTimeWindow->TimeStampB);
time_dif = (pTimeWindow->TimeStampB - pTimeWindow->TimeStampA);
time_dif *= 0.001;
pTimeWindow->TimeStampA = pTimeWindow->TimeStampB;
pTimeWindow->TimeStampB = SDL_GetTicks();

pBuild->count_fps(pTimeWindow->TimeStampB);
}

So maybe (timestep * angle) isn't the right way?

View 13 Replies View Related

C :: Creating PPM Image - Black Rectangle With A Circle

Mar 12, 2013

I'm trying to create a PPM image for a class assignment. A black rectangle with a circle at the point 225, 175 with a radius of 75. I have to use certain specific methods, so I can't use like Bresenham's really famous method for creating a circle.

The problem is that it compiles fine, and transfers to an image fine, but always says that I have a negative or zero image size.

Code:

#include "shapes.h"
int main () {
int i, j, x, y;

fprintf(stdout,"P6 width height 255
");

[Code] ....

And my header is:

Code:
#include <stdio.h>#include <math.h>
#define height 480
#define width 640
#define cy 175
#define cx 225
#define radius 75

The circle has to be filled in. I made it white. Also, i and j are unsused so far, so just ignore them.

View 1 Replies View Related

C :: Program That Calculates The Area And Circumference Of A Circle

Sep 27, 2014

I trying to write a program that calculates the area and circumference of a circle.

This is what I wrote so far.

Code:

#include <stdio.h>
void main()
{
int r;
int pi=3.14159265;
float cir,area;
printf("
enter the radius of the circle ");

[Code]...

the Problem is when I input the radius the answer I get is zero regardless of the the radius. Am I missing something?

View 4 Replies View Related

C/C++ :: Plotting Points On A Circle With One Fixed Axis

Oct 31, 2014

I am working on a computer program where I need to generate points on a circle. I am familiar with this kind of algorithm:

for(d=0; d<=2*pi; d+=0.01)
{
x = cos(d)*radius;
y = sin(d)*radius;
}

However, due to the specifics of the program I am writing, I need to iterate through a fixed number of points one at a time, like so:

for ( int x = 0; x < blockSize; x++ )
{
y = ???
}

This essentially "fixes" one axis of the circle, since I can't do: x=rx+sin(d)*r.

I have tried simply: "y = sin(d)*radius;" and I get a curved shape, but it's not a circle.

My question then is, how do I get the value of y in this situation, where the x axis is incrementing by 1 through a range of values? Is it mathematically possible?

View 6 Replies View Related

C/C++ :: Circle Paper Of Radius R - Max Cone Volume

Jan 23, 2014

My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.

I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.

I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.

#include <iostream>
#include <cmath>
#include <iomanip>
#include <conio.h>
using namespace std;
const double PI = 3.1415;
int main() {
double rem_sec;

[Code] ...

View 5 Replies View Related

C# :: How To Make A Planet That Moves In A Circle Motion

Dec 7, 2014

i would like to make a planet that moves in a circle motion. I dont know how to start and how i can move a "planet" in a circle motion?

View 2 Replies View Related

C++ :: Finding Pi Through Computing Area Of A Quarter Circle?

May 4, 2015

question: Finding pi through computing area of a quarter circle

my code

PHP Code:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int sum=0;            
    double PI,h,x;            
 
[Code] .....

View 14 Replies View Related

C# :: Draw Single Pixel On Window

Mar 27, 2014

Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

Also, what should I be drawing on: the form, panel, picturebox...?

View 2 Replies View Related

C++ :: How To Convert Pixel To Coordinate In OpenGL

May 23, 2013

How can i convert pixel to [-1..1]coordinate in opengl? Which function? I want to write a program that is work with

glutmousefunc(),

When I click on the screen a ball is appear on it where clicked. but mouse work with pixel and circle work with coordinate between -1 and 1 ....

View 4 Replies View Related

C++ :: Subtracting Pixel Values From Two Different BMP Files

Dec 30, 2014

I would like to subtract one image from another to get something like "differential picture" (i am not sure whether the name is correct). I've managed to read the FILEHEADER and FILEINFOHEADER of bitmap. I will subtract 24-bit bmp files only. However i can't understand the structure of this file. So far my code looks like this. Any example of at least copying one bmp file to a new one? This example would be useful, because subtracting will be simillar, instead of copying the pixel value i will just put abs(value1-value2) in the output.

Code:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct BITMAPfileHEADER {

[Code] .....

View 4 Replies View Related

C++ :: SFML 2.0 Pixel Perfect Collision

Oct 15, 2013

I have the code and it compiles fine but it doesn't work. (i am using the coding made easy sfml 2.0 tutorials)

Code:

#include <SFML/Graphics.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
class Player {
public:
sf::Sprite player;

[Code] ....

View 18 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved