C :: Scaling Y Axis - Vertical Histogram
Mar 6, 2015
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.
View 2 Replies
ADVERTISEMENT
Dec 6, 2013
I want to create a vertical histogram in my code. I already made it go vertical but not the way I want it.
Example:
I want it like this:
Range1 Range2 Range3 Range4
And asterisks under each one, depending on the user input. (My code is below and doing it on here doesn't make it come out correctly)
But what I've managed to do is this:
Range1
*
*
*
Range2
*
*
Range3
*
*
*
*
Range4
*
*
Which I don't want. I want everything else to stay pretty much the same since I can only use some features such as Arrays and really basic functions.
Here is my code: (Worked fine last time I used it and I am doing it on Visual Studio 2010 (at uni) and 2013 (on my laptop)).
#include <iostream> //Start of code
using namespace std;
int MarkValueInput; //Mark entered by user
//Counter variables for ranges in While Loop
int counterlow; //Counter for low range
int countermidlow; //Counter for mid-low range
int countermidhigh; //Counter for mid-high range
int counterhigh; //Counter for high range
[Code] .....
View 4 Replies
View Related
Jul 22, 2013
I'm working on creating shaders to be used for displaying text in my openGL programs but am having trouble. I want to be able to scale the text but I don't want to use a uniform ( I want different strings of text to be able to be scaled differently ) so I'm using an in variable. I'm not sure how to use a VBO with a mat4 so instead i've been using a vec2 and trying to convert it to a mat4 in glsl before multiplying it with the position. The problem is that when I run my program, my text isn't scaled; it's just partially missing (the part that is there is about the same size). My vertex shader for this is:
#version 140
in vec2 Position;
in vec4 VertexColor;
in vec2 TexCoord;
in vec2 Scale;
out vec4 Color;
out vec2 UV;
[Code] ....
Also, scaling matrix should look like this:
| x, 0, 0, 0 |
| 0, y, 0, 0 |
| 0, 0, z, 0 |
| 0, 0, 0, 1 |
with z = 1 for 2d scaling, right?
View 4 Replies
View Related
Aug 13, 2013
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 ?
View 9 Replies
View Related
Nov 28, 2011
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.
View 1 Replies
View Related
Nov 30, 2014
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;
[Code].....
View 1 Replies
View Related
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
Oct 15, 2012
When trying to compile, I am receiving errors which I am assuming are pretty generic and common:
lin_interp.c:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
lin_interp.c:100: error: expected '{' at end of input
I am just trying to get the code to work for now. I have created a program similar to this which worked in C++, but the code isn't jiving in C.
Code:
// Lin_Interp.c : Defines the entry point for the console application.
//
#include "PACRXPlc.h" /* Include file applicable for all targets */
#include "ctkInitCBlock.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include <time.h>
#include <ctype.h>
#include <stdio.h>
/* Constants / #defines */
// Print-Out on console "XY LIMIT ARRAY" XYlim
[Code] .....
View 8 Replies
View Related
Apr 10, 2013
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.
View 19 Replies
View Related
Jul 24, 2014
I'm trying to find vertical paths of length n through a 2D grid of numbers. Paths may connect orthogonally or diagonally. An example grid and an example possible path looks like this:
//Grid
0 1 2 3 4 5 6 7
0 2 4 6 4 1 3 4 5
1 5 3 5 8 6 6 6 6
2 3 4 2 1 1 2 5 3
3 3 2 3 3 1 3 4 5
4 3 6 1 1 5 2 5 4
5 2 5 4 2 4 5 6 2
6 6 6 1 1 5 1 4 5
7 1 5 6 4 2 4 2 3
A example possible path of length n = 3 is running from (3,2) to (3,4) - All 1s ...An example of n = 4 is the run of 3s (1,1) (0,2) (0,3), (0,4)
What is an efficient algorithm for solving this kind of problem? I would like to solve (ideally) millions of grids, giving a list for each grid of all possible paths of length for n = 3-6.
View 11 Replies
View Related
Sep 20, 2012
I have an MDI MFC application which has a menu at the top. Nothing particularly unusual about that, but for some reason my application seems to have a vertical spacing about 30%-40% bigger than "normal" on the drop down menus (when compared with Visual Studio itself).
I've looked thru the options for CMenu, CMFCMenuBar, CMFCVisualManager, but can't seem to find anything to explain why my menu has such a large vertical spacing between options, nor how to change it.
View 4 Replies
View Related
Jun 1, 2013
I am attempting to create a program which calculates the product of 4 vertical values in the matrix. The numbers are supposed to be randomly generated and the size of the matrix is given through the command window.
However I seem to have either not pointed my matrix through all of my functions correctly, or my logic is off somewhere as I keep getting this output regardless of the size of matrix I put in:
"the location of the highest horizontal line product is: 5 0 and is the number: 0
The overall max value is 4196352 at the above coordinates."
using namespace::std;
//srand(time(0));
int h_line(int**, int, int);
int v_line(int, int,int);
int diagnol_left(int,int,int);
[Code] .....
View 2 Replies
View Related
Aug 16, 2013
im trying to code a simple list box for my self made GUI but i seem to be stuck at the scroll bar. I already finished with the calculation for the scroll bar size but how I could calculate it's current vertical position depending on the current item on top of the list box.
My current code looks like this
ListBox struct:
struct MenuListBox {
int PosX;
int PosY;
int Width;
int ItemsVisible; //Items visible at the same time
int CurrentItem;
[code]....
Additional vars in the menu class:
MenuListBox* MenuListBoxes;
int ListBoxCount;
How could i calculate this:
New->CurrentScrollBarPosY = ; ?
View 15 Replies
View Related
Feb 21, 2013
How to fix this when i run the program and enter my name then output my name in vertical position using the for loop and press enter the program do not stop
#include<stdio.h>
#include<conio.h>
#include<dos.h>
main() {
char name,n;
clrscr();
printf("Enter Your Name:");
scanf("%c",&name);
[Code] ....
View 3 Replies
View Related
Jan 28, 2014
In a MDI-app with some toolbars and statusbar I created also a controlbar which can be docked to the left side. My problem now: how do I get the exact height of the controlbar?
In CalcDynamicLayout I set the height for the docked state to the height of the mainframe. This value is too big, but it will work basically.
But how can I get the exact height of the controlbar?
View 4 Replies
View Related
Feb 9, 2013
Program that input a name horizontal and display the name in vertical position using looping any kind of looping?
EX.
INPUT:Enter A name:John
OUTPUT:
J
O
H
N
View 3 Replies
View Related
Jun 25, 2013
This program needs to display a vertical graph of asterisks showing production for each plant in the company ...
Here is what I have so far:
***********************************
This program will read data and
display a vertical graph showing
productivity for each plant.
Reference Display 7.8 pg. 401-3
***********************************
*/
#include <iostream>
[Code].....
View 1 Replies
View Related
Apr 8, 2015
I'm having a custom control and I added a vertical scroll bar to it. After scrolling down and then up what all controls are added are disappeared. Controls added are (checkboxes, editboxes, browse button).
Scroll works fine. Looks like painting problem but unable to resolve the issue.
code snippet:
void MyCustomControl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
int minpos, maxpos;
GetScrollRange(SB_VERT, &minpos, &maxpos);
maxpos = GetScrollLimit(SB_VERT);
[Code] ....
View 3 Replies
View Related
Mar 6, 2015
I'm able to get the graph, but now getting the border on the other side of the graph to align it with the right side of my screen.The output looks like that right now because I'm currently playing around with my y axis (right under the for loop) trying to scale everything. I've tried everything many different ways to get this to work.getting the border on the other side of the graph.
Code:
#include<stdio.h>
#include<Windows.h>
int main(void) {
int MAX = 0; //initialize and declare variables
int allcounts [10] = {0}; //store an array of integers for
}
[code]...
View 4 Replies
View Related
Mar 15, 2013
I have following code to create histogram, but it gave wrong output. In the program input_vector read 100 double numbers. I want to create a histogram with bin size=5. Output is [0;0;0;0;0].
Code:
vector<double>three_dimensional_shape_retreival_Hough_Transform:: histogram_creation(vector<double> input_vector) {
long int i;
long int j;
Mat histogram_input(input_vector);
cout<<"Histogram Input Matrix:"<<histogram_input<<endl;
int histSize =5;
[Code] .....
View 4 Replies
View Related
Jun 4, 2013
I was reading a c++ code written in embarcadero ide to add vertical colour text in popup menu.
While reading the code, I had seen following instructions.
private:
Code:
void __fastcall ExpandMenuItemWidth(TObject *Sender, TCanvas *ACanvas,int &Width, int &Height);
Code:
void __fastcall DrawNewItem(TObject *Sender, TCanvas *ACanvas, const TRect &ARect, bool Selected);
The above two methods used in the code like below:
Code:
PopupMenu1->Items->Items[i]->OnMeasureItem = ExpandMenuItemWidth;
PopupMenu1->Items->Items[i]->OnDrawItem = DrawNewItem;
What is happening when we are using member function without parameters like above?
I found above code at: [URL] ....
View 2 Replies
View Related
Mar 6, 2015
have this program .. i tried to make it work to give me this result output:
Code:
input array {1,3,5,1,1,8,6,6,1,3,2,1,6,8,8}
[0]
[1] *****
[2]*
[Code].....
instead i'm having asterisks at the end of the output
View 14 Replies
View Related
Apr 12, 2013
I'm trying to code one of the problems but it really is hard to catch errors for a novice like me at first.
I have to Write a single C function for computing the histogram of a list of nonnegative integers into 4 bins.
The main() function first initializes a positive integer array called List of size N, takes 3 inputs from the user A, B, C (assume 0 < A < B < C), and declares a second integer array Bin[4].
The doBinning function should count the number of elements of List in the interval [0, A) and store it in Bin[0], count of [A, B) in Bin[1], count of elements in [B,C) in Bin[2], and the number of elements >= C in Bin[3]
Code:
#include <stdio.h>
#define N 10
#define M 4
int *doBinning (int source[], int dest[], int a, int b, int c);
int main (){
[Code] ....
Somehow I keep getting error from ptr = doBinning(List[], Bins[]. What am I doing wrong? Code might contain some errors.
View 3 Replies
View Related
Jul 29, 2014
I need a C code for generating a Histogram with intensities at X-axis and number of pixels at Y-axis from a PGM format image.
View 5 Replies
View Related
Mar 9, 2013
I have a text file which consist of several values. These values represent distance from origin to any point in the triangle. How can I create histogram from these values? Is there any functions in OpenCV which can create histogram from these values?
Below my sample values are given:
..........................
3.4 1.2 6.9 0.2 5.1 2.9
........................
View 2 Replies
View Related
Feb 6, 2013
Write a function that generates 1000 normally distributed (Gaussian Probability Distribution) random numbers. Range should be between -3 and +3. Numbers should be double floating point.
There's more to it than that, but I've got it from there.
View 7 Replies
View Related