how to do the mirror function? I have my other two working 100% but for some reason i cannot figure out how to do the mirror part. I want it to be like my flip function(lower code) where I can print the image through the for statement
Code:
int main (int argc, char *argv[]) {
// declarations here
// open input file
FILE *input;
I have been coding this 2D physic engine for quite some time, I work on the many part of these 2 axis ( x and y ) in the same manner is just that one is an x and one is y
So there is a lot of duplicate code
If there is a bug in one part I have to fix the other axis too which becomes a hazzle because I have to fix the duplicates too. The sample code from my program
for( auto it =bodies.begin(); it != bodies.end(); ++ it ){ sf::Vector2f velocity = it->getVelocity(); if( velocity.x != 0 ){ // do some friction force calculation
[Code] ...
It is even more of a hazzle when I work with 4 quadrant, I have 4 duplicate code each ... How do I write a function for both axis ?
I made a working version using absolute vextors being rotated by matrices and keeping relative vecotrs for translations. What I didnt like is that I HAVE TO use the standard XYZ axis for rotation.What I decided to do was use quanternions to store current rotation,cthen buffer rotations each time some were done and add it up.The way I see it, it should look somewhat like this:
(in the UpdateRotation part, plz dont mind any typos i make, this isnt the actual current code. Also on a small note I use dictionaries, so dont be surprised xD) Code: RelativeVectors["Up"] = Vector3.Transform(AbsoluteVectors["Up"], (Quanterion)CurrentRotation); //repeat for Look and Right relative vectors Quanternion Yaw = Quanternion.CreateFromAxisAngle(RelativeVectors["Up"], RotationBuffer["Yaw"]); //repeat for roll and pitch CurrentRotation = Quanternion.Contancate(CurrentRotation,(Yaw*Pitch*Roll)); //
clear the rotation buffer Whats happening right now tho, is that doing this exactly doesnt actually do anything, so I have to use standard axis anyway.
Scaling the yaxis on my histogram for one of my class projects. I've gotten mostly everything but stuck on scaling. I'm pretty sure it's something simple to do, but I'm having trouble, and I've tried everything to my knowledge to get it scaled from 0.1 - 1, like this:
Here is my code:
#include<stdio.h> //include all preprocessor directives #include<Windows.h> int main(void) { int MAX = 0; //initialize and declare variables int allcounts [10] = {0}; //store an array of integers for int yaxis, xaxis = 0;
[Code] ....
I'm close, but every time I try and change my y axis in the for loop from 1 going down to 0.1, it doesn't give me a right output.
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?
I am having trouble of exactly how "class" works. I dont know what the difference between set and get is. I have this code:
#include <iostream> #include <cmath> using namespace std; class Point { private: double px; double py;
[Code] .....
How to get void Triangle::setBottomLeftX(const double x) to work.
Implement the get and set member functions for the class Triangle. Use the appropriate class attributes of the class Triangle.
a. The location of the bottom left vertex is stored in the member attribute blPoint. b. The top left vertex can be computed from blPoint and the height. c. The bottom right vertex can be computed from blPoint and the length.
btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))
I do have a feeling ive done something wrong here (Yes im a noob /> )
Variable active, is the same image as the buttons default (Well should be)
I am working on pset4 in the CS50 online coarse. The goal is to resize a bmp image. I have it working except adding the padding back to new resized image. The image I am using uses 3 bites of padding. If the factor I resize the image by works out to have 3 bites of padding it works perfect and if the image has no padding it works perfectly I need a fresh pair of eyes. I am not sure how to add the images so here is the address to download the images and the skelton of the source code they gave to modify. [URL] .... The image that requires the padding is labled as small.bmp.
#include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char* argv[]) { // ensure proper usage if (argc != 4)
I am trying to display images on top of my Background image gui, so like buttons an stuff but the problem is that there not showing ontop. I can only get one of them to show
// includes #include <windows.h> #include <stdio.h> #include "res.h"
The problem i have faced is image is getting cropped.
I want to rotate an image without cropping. I have searched a lot but I am not getting any algorithm based on C. How to get the algorithm for image rotation without cropping.
I'm trying to edit an image by multiplying the red component of each pixel by 10 and leaving the other components (green and blue) untouched. I'm not really sure how I'm supposed to edit the pixels one by one. I have this so far. I think there is something wrong with my ppm header as well. Is there a way to make a ppm header without specifying the bounds so that it conforms to the image you are putting in?
I am trying to read a 24 bit image but I'm getting errors when I'm tryting to read the pixels.
-The reading part looks bad because I'm reading both headers field by field. But I'm sure that it is reading both headers correctly.
-Right now my biggest concern is to get it to read successfully an entire bmp image
I'm using this calculation to get my padding bytes:
padding bytes = [4-(3*width)mod 4]mod 4
When I use a 2x2.bmp file to test it, I get an error that the [1][1] pixel was not read. When I use a bigger image it gives me the same error after about 100 rows and then every pixel is an error from that point on. This is what I got so far:
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.
I'm pretty new to C, just looking to see how to display a image and some text to go along with it so far I can display in the image but cannot display the text at the same time.
I have an assignment where I need to take an assigned image, rotate it 90 degrees to the right, flip it upside down, and turn it to grayscale; each with different outputs.
I was thinking if I can read in the image into a 2d array //array[height][width] or even just an array with the values of each pixel (r, g, b), I can just modify the array and spit it out when done.
if i can just get it into the array, I think I'll be fine. We've done similar assignments with modifying arrays for grayscale images and the other two I can probably figure out. But how am I going to read in each pixel into an array with three different values in each slot? This is my code so far:
I am trying to re-size a bitmap image for a class.They gave us two options to use to do the program with: an array or move the file position indicator. I want to use the file option. All the bitmap header info is checking out. The file after being re-sized should be 822 bytes but it is 1.6 KiB and the image is distorted.
Code:
#include <stdint.h> /** * Common Data Types * * The data types in this section are essentially aliases for C/C++ * primitive data types.
This is my first time using opengl and I am experimenting with adding/drawing polygons/points/etc. on top of a PPM image. The image is already loaded when the application runs. My attempt to draw a square is from lines 30 - 35. The program runs but the square is not present. Just the image.
My assignment is use a 3D array to create an image. Use an array of the form arr[300][200][3]. For this homework, you need to use an array of the form arr[3][400][500]. It will have 400 rows and 500 columns. You need to first initialize the array as described in class and after that write the array to a ppm image file. When viewed using Gimp, it should display USM. The letters would be 200 pixels high and 100 pixels wide each. Use at least 15 pixels for the width of the stroke. Use different colors for each letter and a different color for the background.This is what I have so far.
#include <iostream> #include <fstream> #include <string> using namespace std;
void initialize(unsigned char a[][200][3], int nrows, int ncols, int nc); void printAll(unsigned char a[][200][3], int nrows, int ncols, int nc);
so im trying to make a background for a menu, but it is only so big. its not the kind of picture where i can just reapply it. is there a function to make it fill to the screen?
Our teacher wants us to make a timeline showing a picture from each year of our lives. I thought of a creative way of doing this in c++, make the user input the year they want to see, then make the image popup on the screen. Is this possible and how would I go about doing this? Here is the code I have so far:
#include <iostream> using namespace std; int main() { int userInput; cout << "Hello and welcome to my timeline!" << endl; cout << "Please type in what year you would like to see and press enter" << endl;