For a larger program I need a way to tell if a "lock knob" is going clockwise or counterclockwise. So below, I have my MoveLock function (That our teacher actually gave us to use) that reads inputs from the arrow keys and displays them. But what I need is to be able to count each time its moved in the correct direction and to reset the count it if it has gone in the other. Right now I'm just testing if it's going clockwise. I thought to solve this by resetting the count if it was less than the returned value from MoveLock (which is a count to compare to the former). Currently, it only displays the current position and the count as -1 or 1.
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).
Write a program that creates the output shown in the Output Layout section below. The program should create 2 points with x and y coordinates as integers, prompt the user to input the x and y values for one of the points and randomly set the other (-99 to 99 range) and output the length of the radius line segment and the area of the circle that radius defines. The program should then end. Include an SDM for the program and any other appropriate documentation.
Special Calculations: Distance between 2 points equation: √((p0x – p1x)2 + (p0y – p1y)2) (This requires use of the math library)
Output Layout: (bold text represents user input)
Please enter the location of your first point. Enter a value from -99 to 99 for your x coordinate: -2 Enter a value from -99 to 99 for your y coordinate: 17
The location of your second randomly set point. Your x coordinate: 45 Your y coordinate: -89
The length of the radius line segment from point one to point two is 115. The area of the circle with a radius of 115 is 41546.33.
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?
I'm implementing a quad tree for an assignment, and I'm not sure if every node should contain a list of pointers to every Point in its sub tree (implying the root node will contain all Points), or if only leaf nodes should contain the Points.
Today i am going find out solution of two ellipses intersection points using C programming, I solved using geometry equation substitute method but i am not unable to do same thing in C programming.I am talking example as following two ellipses (x^2)/4+y^2=1 , ((x-2)^2)/4+y^2=1
As homework we were assigned to enter the following code to calculate the distance between two points on the x and y plane. The program should ask the user to enter two points then should calculate the distance between two points and print the distance on the screen.
My program will compile correctly but when attempting to run the actual program it doesnt do anything and some how completely skips over my main function...
I have a program that is trying to find all factors of an integer given. It needs to be done in a recursion function. Right now i have code similar to just getting the prime factors of a integer.
unsigned int * find_factors_using_recursion(unsigned int x ) { unsigned int * factor = new unsigned int[];//do i put x in here ? for(unsigned int i = 2; i < x; ++i) { if(x % i == 0) { find_factors_using_recursion(x / i); *factor = (factor[i] = i); } } return factor; delete [] factor; }
When i cout the *factor = (factor[i] = i) it gives me the prime numbers of the integer passed into the function but when I return the pointer it only returns one of the prime numbers. I'm new to c++, how to return pointers from functions that would be great with an example to go with it.
I'm creating a quick program to calculate midpoint and distance between two points. I'm having a little trouble. This is the program:
//This program is a start to solve basic coordinatre plane distances and midpoints #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; int main(int nNumberofArgs, char* pszArgs[]){ cout << "This is a calculator to find distance and the midpoint between two points. " ;
[Code]...
the problem is that the output for both equations is wrong, it doesn't do the math properly and I assume it has to do with the variable types I'm using but am not sure. P.S. I am using the latest version of DEV-C++
I'm playing with my final year project, building a game boy emulator in C, and I wanted to try out something to streamline my code base. I'm building against Win32, GNU C and Googles Native Client.There are no platform specific headers or functions in use. What I'm trying to do is have a file that conditionally includes the entry point (so _tmain for Windows etc) based on a preprocessor directive being set/not-set.
[note] I realise I could write both entry point classes in one file and use the preprocessor directive in there, but it's not as neat as a single file calling in one or the other. I figure this should work because I can conditionally include headers for Win/NaCl (providing the signatures match, of course).
I have been trying for hours to create a specific prototype program that determines a pascal's triangle for a give number of rows. However, prototype must have the return type of int**. I just recently learnt about pointers, why my attempt of the function doesn't work. As well, i am not sure how I can check if my return value actually points to the pascal triangle.
Code:
#include <stdio.h> #include <stdlib.h> int **getPascalTriangle(int n) }
I am trying to write a function that calculates the Euclidean distance between two points described by 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 = √(𝑥1 − 𝑥2)2 + (𝑦1 − 𝑦2)2 Input Prompt Enter x1, y1, and x2, y2: Output Prompt The distance is XXXX.XXX
Replace XXXX.XXX with the calculated distance precise to three decimal points.
Will this be a smilier input to the same forum that wasted posted a few years ago on this site?
In this project you are asked to find K nearest neighbors of all points on a 2D space. The distance metric that you are going to use is simply the Euclidean distance example;
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'm in need of an algorithm to find the points within a triangle(vertices are known. 3d coordinates). The points are to be at same distance from one another i.e. the points are uniformly distributed within the triangle.
I have done a search about the topic and have come across some ideas like lattice points generation ,tiling polygons with Lattice triangles [URL] .... and taking their centroids as the points.
How to accumulate the reduction in health points in the loop. I have structured my program so it calls to 2 functions during the loop. These are the playerStrike() and computerStrike(). They seem to be looping well with the one exception that the counters reset back to 100 health points each time. I know it's reloading the original variable amount but how to prevent it from doing this.
I am Trying all the Time to implement in c# moving of points by using Mouse ( Web Applications) and save the new value in array. But not successful ...