C++ :: Sphere Center And Radius From 4 Points

Jun 22, 2013

Any class or library that can to calculate the center and radius of a sphere from 4 known points on its surface?

View 9 Replies


ADVERTISEMENT

Visual C++ :: Drawing (radius Sized) Lines From Center To Boundary Of Circle

Feb 3, 2014

I am facing a programming logic problem. I want to draw radius sized lines from centre of circle to the circle boundary.

My code is:

int x1, y1, x2, y2, i, r, old_xc,old_yc, x,y;
int xc, yc;
x1=170;
y1=300;
x2=70;
y2=400;
pDC->Ellipse(x1,y1,x2,y2);

[Code] .....

The lines are touching the circle boudary at only start while the rest of lines are smaller and the shape is a triangle instead of a pie slice.

View 8 Replies View Related

C/C++ :: Applying Texture To Sphere?

Apr 19, 2015

I am currently trying to apply a texture to a sphere I made, and have been following various tutorials. My program no longer crashes (used to be a problem but I figured it out), but the texture isn't being applied to the sphere. I used glut and SOIL to do this, but I am pretty sure that I am missing some necessary code from my own program for the textures to work. Because my program is a bit different from the tutorials though, I can't figure out what it is that I am missing. Below is what I have written to this point. It all compiles, and it successfully displays two objects (a sphere, and a pyramid), but neither object has textures, the pyramid simply has the colors it was set with (supposed to, I want to texture map the sphere first), while the sphere is a solid blue. What am I missing or what do I need to move?

#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>

[code]....

View 9 Replies View Related

C/C++ :: Find Maximal Points Among Given N Points

Nov 3, 2014

Example: In a 2-D space, point A=(a1,a2) is bigger than point B=(b1,b2), if a1>b1 and a2>b2.

How do I write a presudo code to find all the maximal points among the given n points?

View 14 Replies View Related

C :: How To Center Text Using Printf

Jul 23, 2014

The overall width of the line is 20 characters. How can I center a string using print so that

title becomes
space-title-space

i have something like this so far Code: fprintf(myfile, "%20s ",mystring);

View 2 Replies View Related

C# :: Printing Picture Not Come On Center Of Page?

Jun 11, 2014

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap myBitmap1 = new Bitmap(pictureBox1.Width,pictureBox1.Height);
pictureBox1.DrawToBitmap(myBitmap1, new Rectangle(0 , 0, pictureBox1.Width, pictureBox1.Height));
e.Graphics.DrawImage(myBitmap1, 0, 0);

[Code]...

when i print picture exist in picture box image come on top right why i need image come on center of page

View 2 Replies View Related

C++ :: How To Update Coordinates To Move It Towards Center And Then Nuclei

Jan 22, 2013

I have created a sphere, inside the sphere (cell) is another smaller sphere (nuclei) located at one end and at the other end of the sphere is a structure call microtubules.The microtubules had a center point and then there are line that extend from the point to the edge of nuclei and also to the edge of the cell.

I have points (viruses) that move throughout the cell. Once the virus is on the microtubules structure ( assuming it attaches to the structure from the cell edge), it must move towards the center of the microtubules and eventually move down the line towards the nuclei.

I have already figured out how to determine if the virus is on the microtubules structure however I cant figure out how to move it down the line. I figured it out in 2D space using the quadrant system, but I cant wrap my head doing it in 3D space.Once the virus is on the microtubules how do I update the coordinates to move it towards the center and then towards the nuclei?

View 3 Replies View Related

C :: Printf Alignment - Prints Out Text In The Center Of Window

Jul 19, 2013

I'm trying to find out, how to do printf so that it prints out text in the center of the window. I know how left and right justifyment is... but how to get to the center? C...

View 2 Replies View Related

C/C++ :: Program That Uses The Radius To Get Area?

Apr 28, 2012

How can i come up with a program that uses entered radius of a circle to find its area

View 1 Replies View Related

C++ :: Add Constructor That Accepts One Argument And Uses It To Set Radius

Apr 10, 2013

I'm getting a error on my Circle::Circle(double radiusValue) constructor. My instructions is 'Add a constructor that accepts one argument and uses it to set the radius.'

#include <iostream>
#include <cmath>
using namespace std;
class Circle {
private:
double x;
double y;
double radius;

[Code] .....

View 3 Replies View Related

C/C++ :: Calculate Radius Of Cylindrical Rod In Inches

Feb 14, 2014

Exerted by the rider's foot yet not exceed the stress placed on the crank arm's sprocket attachment, is provided by this formua:

r^3 = d*p/s*π

r is the radius of the cylindrical rod in inches. d is the length of the crank arm in inches. P is the weight placed on the pedal in lbs. S is the stress in lbs/in2

Using this information, design, write, compile, and execute a C++ program that computes the value of r for a crank arm that is 7 inches long, accommodates a maximum weight of 300 lbs, and is able to sustain a stress of 10,000 lbs/in2.

View 1 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/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/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++ :: 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++ :: Distance Between 2 Points Equation

Apr 14, 2013

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.

Other:

int pAx;
int pAy;
int pBx;
int pBy;

View 3 Replies View Related

C++ :: Sorting 2D Points Clockwise

Nov 7, 2013

I have 2D points written in {x1, y1, x2, y2, x3, y3, .....}

#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
vector<double> vec;
vector<double> vec_ordered;

[Code] .....

Result.

6 4
6 3
6 2
6 1
5 5
5 1
4 4
4 1
3 3
3 1
2 2
2 1
1 1

which wrong result

I wanted to make

6 3
6 2
6 1
5 1
4 1
3 1
2 1
1 1
2 2
3 3
4 4
5 5

View 6 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++ :: Calculate Distance Between Two Points

May 15, 2014

It ougth to calculate the distance between two point (p1,p2)

"main.cpp"
#include "distancia.h"
void main () {
Point p1,p2;

[code]....

View 4 Replies View Related

C++ :: Memory Points Not Working?

Jul 23, 2013

This is the source code.
--------------------------------------------------------------------------------

#include <iostream>
#include <windows.h>
using namespace std;
int main(){

[Code]....

When I type a word, it gives me the first letter of the word, then a symbol, or nothing.

View 3 Replies View Related

C++ :: Closest Distance 2D Points?

Oct 29, 2014

In the following code I don't understand why am I splitting the y left and y right.

(closest distance between 2 points in 2D)

Am I splitting the y left and y right so that I can concatenate them afterwards and then build the strip,only according to these concatenated halves ?

PS : Finding the min. distance between sorted x right and x left works fine , only problem is with the strip.

#ifndef CLOSESTPAIR_H_
#define CLOSESTPAIR_H_
#include <float.h>
#include <math.h>
typedef struct Point2D {
double x;
double y;

[code].....

View 4 Replies View Related

C++ :: QuadTree - Should Non-Leaf Nodes Contain Points

Oct 25, 2013

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.

View 4 Replies View Related

C :: Finding Intersection Points Of Two Ellipses

Oct 16, 2014

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

View 11 Replies View Related

C :: Calculating Distance Between Two Points (x And Y Vars)

Feb 23, 2013

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...

Code:

#include <stdio.h>
#include <math.h>
struct point {
float x;
float y;

[Code] ....

View 2 Replies View Related

C++ :: Returning Pointer That Points To Array

Mar 5, 2013

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.

View 10 Replies View Related

C++ :: Calculate Midpoint And Distance Between Two Points

Sep 25, 2013

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++

View 12 Replies View Related







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