C++ :: Make Object Coordinates Moving In Straight Line With Angle Have A Sinus?

Sep 22, 2013

I want to make an object, which moves from x1,y1 to x2,y2 in a straight line, also make a sinus over the line (so the x,0 is the line itself, and cux,cury is the object. So the object will move as a sinus over the line. How do I do this in c++?

View 3 Replies


ADVERTISEMENT

C :: How To Print Strings On The Same Line Without Moving To Next Line

Mar 12, 2013

Just working up for the google coding contest to start soon and have been practising some of the test questions however i make correct algorithms but my output is rejected because of the fact that my strings are printed on a new line so i wish to know a method to print strings using a printf statement or any other function on the same line ...

View 3 Replies View Related

C++ :: How To Predict New Compass Angle Of Object With Information

Apr 16, 2012

In a cartesian coordinate system, I want to be able to predict a compass angle of an object. So I have a base position of (0,0) and then a distance and compass angle to an object. This object also has a heading and a speed. How can I predict the new compass angle of the object with that information?

my coordinate system is like this:

Code:
0 y
|
|
270-------------- 90 x
|
|
180

I think the first step would be to compute the cartesian coordinates of the object:

float degs_to_rads = 3.141592653589793 / 180.0;
x = distance * sin(angle*degs_to_rads);
y = distance * cos(angle*degs_to_rads);

then the next step would be to compute the predicted x and y from the speed and heading of the object:

predictedx = ??
predictedy = ??

then finally convert back to an angle, and distance:

newDistance = sqrt(predictedx^2 + predictedy^2);
newAngle = atan2(predictedy, predictedx);

fill in the blanks?? Are my other things correct?

View 10 Replies View Related

C++ :: Moving Object In Array

Nov 30, 2014

I want to make an object in array[][] move

Ex:
array[2][5]
array[0][0] = 'O'

O| | | | |
| | | | |
| | | | |

then
|O| | | |
| | | | |
| | | | |

then
| |O| | |
| | | | |
| | | | |

......

how can i print my array in console then change&print it again, then change&print it again,... So it look like O is moving
???

View 1 Replies View Related

C++ :: How To Rotate Single 3D Object By Modifying Its Coordinates

Jun 20, 2014

I would like to understand how to rotate a 3D Object around it's Center, by modifying it's Vertex Coordinates. N

The reason is that I need to keep track of the new coordinates because of my collision system, which is based on Vertex Coords.

Here is the Code for an Object

void DrawHouse(GLfloat x1, GLfloat x2, GLfloat y1, GLfloat y2,
GLfloat z1,GLfloat z2, GLfloat u1, GLfloat u2, GLfloat v1, GLfloat v2, GLuint textid) {
glBindTexture(GL_TEXTURE_2D, textid);
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(u1,v1); glVertex3f(x1,y1,z2);

[code]....

View 7 Replies View Related

C++ :: How To Enter And Print X And Y Coordinates On One Line Separated By Comma

Nov 22, 2014

I'm trying to enter an 'x' and 'y' coordinate on only one line separated by a comma. But I keep getting a syntax error. Here are the lines of code I'm using. This has to be simple. What am I doing wrong with this code?

Code:
cout<< "Please enter the x and the y coordinates of the first point,"<<endl;
cout<< "use a comma to separate them. " <<endl<<endl;
cin>> "You entered: " >>x1>>",">> y1 >>"for the first point" >>endl;

View 7 Replies View Related

C# :: Making Moving Button Or Moving Picture Box Clickable?

Jun 13, 2014

i want to make moving button or moving box clickable as i am making a game in which i move picture boxes and user clicks on it and his scores increases. but i was unable to do so , so i tried the same concept with buttons but no results.

View 7 Replies View Related

C++ :: Fitting Data With Sinus Fit

Feb 7, 2014

I want do fit data with a sinus fit. I found an algorithm, unfortunately I do not see how to give the data to the algorithm.

float * datax = new float[numOfData]; float * datay = new float[numOfData];
float * dataz = new float[numOfData]; float phase(0); float mag(0);
for(int i=0;i // fill data
float a(0); float b(0); float c(0); float p[3] = {0}; // product of fitting equation float XiYi(0); float XiZi(0);
float YiZi(0); float XiXi(0); float YiYi(0); float Xi(0); float Yi(0); float Zi(0); for(int i=0;i

[Code] ....

View 6 Replies View Related

C++ :: Data Fitting Routines (Sinus Or Linear Fit)

Feb 5, 2014

Looking for data fitting routines?

I want to fit datapoints with a sinus or with a linear fit.

View 3 Replies View Related

C/C++ :: Make Multi Cout / Cin In The Same Line?

Nov 17, 2014

#include<iostream.h>
#include<conio.h>
main()

[Code]....

I tried to make the output look like this --> ENTER YOUR NAME:Victor Collin ENTER YOUR COURSE:BSComSci
but everytime I entered my name the course went to the next line.How to make the output in the same?

View 7 Replies View Related

C++ :: Convert Binary To Base10 - Array Initialization Skipping Straight To Int Main?

Mar 3, 2013

I am attempting to write a program that converts binary to base10, and vice versa.

But in the function for converting Base10 to Binary, just as it reaches the line of code

int* binary = new int [a];
it skips straight to the int main()

All I'm attempting to do with that line of code is initialize the variable "a" into the elements of the array "binary".

[URL] ....

View 5 Replies View Related

C/C++ :: Making Offsets - Addressing Formula Of Straight Forward N Dimensional Array

Apr 12, 2014

I know how to make offsets/addressing formula of a straight forward N Dimensional array but how to make an offset and a storage allocation space for something tricky like:

1. A lower and upper triangular matrix?
2. A band matrix?
3. Making an offset for ragged arrays which have different row lengths?
4.A upper/lower triangular matrix using ragged arrays?

This is not for an assignment but preparation for an exam. I don't know how to go about on finding these out.

View 14 Replies View Related

C++ :: Make Object Rotate Until It Looks At The Sprite?

Oct 10, 2013

Is there a way to make an object rotate until it looks at the sprite?

View 1 Replies View Related

C++ :: How To Make Object Wrap Around The Screen

Apr 2, 2013

How to make an object wrap around the screen?

View 1 Replies View Related

C/C++ :: Make Class That Can Only Have One Object Of It Created?

Oct 7, 2014

make a class that you can make only one Object of it.

For example if you have Class A.
Let's say you create one object A* a=new A();

Now the next time you, try to create another object. For example:

A* b=new A(); What will happen is that b will get the same object (or reference) as a. In other words hey'll be pointing towards the same place. So basically you'll only have one object of it created. I tried doing it but I couldn't quite make it.

Here is what I tried: (but couldn't complete the exercise)

class God
{
public:
static int num;
static God* god;

[Code]....

View 2 Replies View Related

C/C++ :: How To Make Object Move In A Maze

Apr 29, 2013

What c++ code can be used to make an 'X' move through a maze. I have some code, but I'm not sure where to go from there. I have divided the program into three files, A header file, a main file and a .cpp implementation file.

In my implementation file I have:

#include "Maze.h"  
Maze::Maze() {  
} void Maze::mazeTraversal(char maze[][COLS], int row, int col, int direction) {
    enum Direction {DOWN, RIGHT, UP, LEFT};  
    switch(option)

[Code] ....

View 1 Replies View Related

C :: Make Fgets Stop Reading When It Reaches A New Line?

Apr 13, 2014

How can I make fgets stop reading when it reaches a new line? Right now it will read the new line and continue until the buffer is full. I was thinking something like this.

Code:
while(fp!='
'){
fgets(password, 256, fp);
}

View 2 Replies View Related

C++ :: Program To Make Shopping List - One Line Per Entry

Jan 9, 2015

OK I'm making a simple program to make a shopping list. I would like the program at start up to load the previous shopping list that was saved as a text file. The format is one line per entry which consists of the category or Isle, and the item description. Here's an example:

3 Dog Food
Produce Sweet Onions

I reading the first word, and then I want to read the rest of the line which may have more than one word... the problem is my code hangs... or goes into the old infinite loop. It doesn't see the end of file.

Here is my code:

void
addItemsFromFile(vector<item> &shoppingListVector) {
string word;
char buf[30];
if (fileExists("shoppinglist.txt"))

[Code] .....

View 3 Replies View Related

C Sharp :: How To Make Object In Form1 Work In Form2

May 20, 2012

I've got a calendar in Form 1 in my code, and buttons in Form2. I need these buttons to send codes for this calendar in Form1. How may I make these work? My friend told me to do a function as a new class, but I'm not sure how can I do this.

View 5 Replies View Related

C :: Make Array Stop Reading From Input When It Hits A New Line?

Nov 25, 2013

I want the numbers to be put into the array until it hits a new line. Maximum number of numbers is 1000. What can I replace that while loop with to stop it from reading further into the input file?

Code:

while (input != '
'){
for(i=0; i<1000; i++)
fscanf(ifp, "%lf", &auctions_prices[i]);

View 2 Replies View Related

C :: How To Emulate Object Orientation With Multiple Files And Make File

Feb 13, 2013

how to structure my classes so that they all "wire together" and inherit the proper functions and data that I want them to. I want to have a Car.c and car.h which are "wired" with body.c/body.h, which in turn is wired with a frame.c/frame.h, wheel.c/wheel.h, and driver.c/driver.h.

Each part of the car holds some type of data, mostly ints: The car has a (total) mass and car_name. The body has a mass and color. The frame has a mass. The wheel(s) have a mass and force. [There will be 4 instances of wheel] The driver has a mass and driver_name. Each of these functionalities must come from their respective .c and .h files, and be amalgamated in the car.c and car.h (which should contain all the functionality of its parts). Then, in my main test program, I am to make an instance of car and hardcode in its values of: mass (which comes from the total mass of all of its parts, this is where i start to lose it.

How will I access its parts' masses in the test program?), color (a character array), current position (an integer), current velocity (an integer), and current acceleration (which comes from the total newton force of the 4 wheels, again this is where I start to get very confused). (Then in the test program I am to print out a simulation of this car over a period of 100 seconds, and show its position, velocity, and acceleration at each point (based on the mass, total newton force, and starting position). This part is of course a simple while loop, and is somewhat trivial.)

From what I understand, I will need to allocate memory for all of the data each class holds. Then, using function pointers, as well as #include "X.h" , I will need to somehow link up all of the classes together so that car has access to all of the parts' functions which set, for example, the newton force of each wheel.

We have learned a slight bit about structs, malloc, sizeof, and pointers, but I have not used them to link functionality or data from separate classes together.

View 4 Replies View Related

C++ :: Angle Between Two Points

Apr 19, 2014

i'm working on a robotics project, to move the robot from it's current position to target position i need to calculate the angle first before i can move the robot.this the code I use to calculate the angle:

double cal_angle ( int current_x , int current_y , int tar_x , int tar_y )
{
return atan2(tar_y - current_y, tar_x - current_x);
}
int main ()

[code]....

as u can see the angle between x4,y4 to x1,y1 should be 3.14 (180)however , the result are correct as long as the distance from the current position to target position > 1 (not sure actually).

View 2 Replies View Related

C++ :: Calculate The Angle Between Two Vectors

Feb 20, 2014

My question is not in c++ programing , but because my aim is to make code that calculate the three angles between two vector i ask my question here

So as the title i have three point that create two vector and I want to get the angles in x,y and z of the point2

I used crosproduct that give me one angle without axe , I don't know in which axe this angle

My aim is the three angles for the 3 axes ....

View 7 Replies View Related

C++ :: Finding Angle From 3 Points

Nov 10, 2013

I am making a game and I am trying to rotate an image so that it is always pointing at the player. I have two lines, the first point of both of them is on the image and the second point of one line is on the last position of the player, and the second point of the other one is on the current position of the player. To rotate the image I need to get the angle between the two lines. how I can get that angle with only the points from the lines?

View 7 Replies View Related

C++ :: Get Angle Of Bullet After Bouncing?

Jun 30, 2014

I'm trying to make a bullet bounce after it hits a wall. I think bouncing on the top and bottom wall works perfectly, but it won't bounce off of the left and right walls. How would I get it to bounce? This is how I get the direction the bullet it going whenever I shoot.

player.dir = GetAngle(player.mouseX, player.mouseY, player.x, player.y);
float GetAngle(float x1, float y1, float x2, float y2) {
return atan2(y1 - y2, x1 - x2);
}

Also what I was trying to do to make the bullet bounce.

if (bullets[i].x < 10 || bullets[i].x > screenWidth - 10 ||
bullets[i].y < 10 || bullets[i].y > screenHeight - 10) {
if (bullets[i].type == 8)
bullets[i].dir *= -1;
}

View 3 Replies View Related

C++ :: Hypotenuse For ONE Side And ONE Angle?

Dec 7, 2014

On a right angled triangle, if the user inputs only ONE side length (not the hypotenuse) and only ONE angle, what code is required to work out the hypotenuse? I know how to work out the final side and the remaining angle once I have this.

View 4 Replies View Related







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