now that I can pick a mesh I want to put it in the ground.So I'm looking for the 3d position of my mouse in the ground.this is my code about picking:
D3DXMATRIX p_matProjection, p_matView, p_matWorld, p_matInverse;
pDevice->GetTransform(D3DTS_PROJECTION,&p_matProjection);
pDevice->GetTransform(D3DTS_VIEW, &p_matView);
pDevice->GetTransform(D3DTS_WORLD, &p_matWorld);
// use the mouse coordinates to get the mouse angle
I've got an error saying that there is an access violation at 0x0000040 error no 0xC0000005
I've searched the net, saying the error may be due to an uninitialzed variable.I debugged the code, and found out that an object created from directx D3DXMATRIXA16 is uninitialized.With values ??,??,?? in each element
pMeshContainer->pBoneMatrices = new D3DXMATRIXA16[g_NumBoneMatricesMax];
here, pMeshContainer is a variable passed into a function called GenerateSkinnedMesh by pointer
when the method CreateMeshContainer finished execution, the meshContainer is passed back to its parent like this
*ppMeshContainer = pMeshContainer;
The whole meshContainer stuff is stored persistently inside the frame root wrapped within a class called CMesh So in that process, I haven't initialized pBoneMatrices in anyways. But what and where is the best way to initialize an array of DirectX9 objects.
There is a function called
D3DXMatrixIdentity(&...);
But how can I initialize each one of them with this call?
Notice that pMeshContainer->pBoneMatrices does contain a valid address, despite the fact that the elements inside it are never initialized...
I have one code that use MPI broadcast and I want to change it into Asynchronous Point to Point communication. I am newbie in Parallel programming. Looking for implementation of one simple same program in broadcast and P2P ?
I don't know why this doesn't work. It doesn't return any errors, but it does the polynomial equation wrong. I tried using "^" instead of "pow" and it still does it wrong. I'm getting results like "-897123897" instead of "3". This is the code:
Code: #include <stdio.h> #include <conio.h> #include <math.h> int main() [code]....
I am reading about positive and negative infinity in c++ and i am trying to implement them in a fixed point math arthimethic implementation
I can see that max of a int will be equal to std::numeric_limits<int>::max(); and min value of the int will be equal to std::numeric_limits<int>::min(); in c++
Here as i am defining the int max and int min manually in my fixed point math implementation, my doubt is int min = -int max; or int min = -int max -1; ?
If i do run the above program in turbo C/C++ complier, it outputs "h". But,if i change the code as i=0.6 and if (i<0.6), it outputs "w". Even if i change it to i=0.8 and if(i<0.8), then also it outputs "w".
In the above program, I am calculating the square of float number. But sometimes the number is entered as NAN and sometimes Output is NAN. What is NAN? I am entering floating point number, then y NAN is entered?
I have been writing a fixed point library the would handle fixed point numbers with an 8:24 whole/fraction ratio. This has been working quite well but since I have a 24 bit fractional part, it should be able to store 2^(-24).
Code: long long fraction_part = 0; long long divisor = 1;
The issue here is that since the smallest possible fraction is 2^(-24) the divisor could end up needing more than 64 bits and so won't work. I'm not quite sure how else I could do this.
I'm wondering about the point of pointers to functions. When is it used?I saw the below example. It doesn't make sense to me. I mean we can easily write code that does the same without having to use pointers.
Code:
#include <stdio.h> int addInt(int a, int b); // Adds 2 integers int add5to4(int (*function_pointer)(int, int)); int main(void) { int sum; int (*function_pointer)(int, int); }
Program which accepts two lines and and determines their intersection point and whether they lie within a circle, also given interactively. I'm racing against time and I've racked my skull to no avail
I dont see any point of NULL in cstring. The code given below just outputs same as it would have done with NULL. My understanding is if size of char array is less than length of char array then null must be manually added?
#include <iostream> using namespace std; int main(){ char chr[0]; cin>>chr;//or if you use cin.getline; cout<<chr<<endl; return 0; }
Enter something: hellowwwww hellowwwww Segmentation fault (core dumped)
I'm developing a short c++ program to scan all devices connected to the system through the USB connections.
I have used libusb to scan them and it really works but this library does not provide me with the mounting point, so I get a list of devices including manufacturer, serial number, etc but not the mounting point.
I have also used libudev library but it seems to happen something similar...
I need to get the mounting point for all USB devices connected to the board, you know: /dev/ttyUSB0 ....
So, I have created a class called "point" and i have 4 "point" objects. They only have 2 variables, x and y (their position). The first 3 points form a triangle and now I need to tell if the forth one is inside or outside. I have found some solutions but they involve heavy math (they are based on the sum of the angles or something like that). I want to know if there is any way to solve this only by using the distance between points. I have created a function which takes 2 "point" objects and returns a float value which is their distance.
Here is some code:
#include <iostream> #include <cstdlib> #include <math.h> using namespace std;
I am trying to write a basic editor program and one of the parts asks me to "process dot commands that move point in whole line increments"
Earlier it says that a point is interpreted as specifying the location between characters rather than the characters themselves. and i need to use this to implements the following:
< moves point to the beginning of the document. > moves point to the end of the document. p moves point to the beginning of the previous line. n moves point to the beginning of the next line. k deletes the current line and leaves point at the beginning of the following line.
(there was a previous part before this so i already have some code that works) and in this part I'm trying to do a switch case
ie
for < , >, p , n and k
I guess my question is how do i make this "point" need. Ive been using vectors, so the point needs to be somewhere inside the vector. I don't think ill be able to do what i need to do with out the point.
I am having trouble understanding the mantissa of a floating point number. I have divided up the floating point number into the sign bit, the exponent and the mantissa, I have found the exponent, but I am not sure what to do with the mantissa? From what I have gathered so far i divide the mantissa by ten until I get a number between 1 and 10. after that i convert the number into a decimal with everything after the decimal point (or radix) being a fractional number. But when I do that on paper I dont get my intended number. How do i put the exponent and mantissa together to make a decimal from my floating point?
ex. input is 00111010000111111111011000001000 sign is 0 exponent is 01110100 which is 64+32+16+4-127=-11 mantissa is 00111111111011000001000 which would be 1.11111111011000001
When i convert that i get 1.99756622314 i dont know what to do with the -11 exponent and the answer i want is 6.1e-4
I'm trying to convert 4 hex register into floating point value using IEEE 754 floating point format. My device will reply 4 register value. The problem is that it always reply for example 0x10 as 10 when i use getc() hence using char variable to store it is not ideal.
A function finds approximate maximum or minimum point of a second degree polynomial function (the point where the derivation will equal to zero ). The input polynomial function will be in the following format:
x2 + bx + c = 0 .
Your C function should take a , b and c as input parameters. Your C function also should take the srch_starting_point and stp_sze from the user. Finally, print the resulting maximum or minimum point (m_x, m_y) and step count (n_step) in your function.
For example, if the input is (a, b, c, srch_starting_point, stp_sze ); 1 1 1 -3 1
Output similar to; Maximum point results ( m_x, m_y, n_step ) -1 1 2
i can find the minimum point at first(Using derivation). After choosing starting point, staating point gets lower step size by step size. I can compare numbers to the minimum number. Afterwards, to find m_y i put m_x in the function. Finally, I put a counter to count steps.
I have write a program to read ppm file and write a new ppm file. However, I'm not sure how to find the darkest point in this ppm file.
Note: 1. there are 610200 RGB point, but my new file only created 176196 RGB point. 2. RGB range: 0-255. (0,0,0)= black; (255,255,255)= white 3. When reporting the location of your dark pixels, assume the upper left corner of the image is location 1, 1
Write a function named "sum" that takes as its arguments the following:
(1) an array of floating point values. (2) an integer that tells how many floating point values are in the array.
The function should return as its value the sum of the floating point values. For example, if the array that's passed to the function looks like this: 0 1 2 3 4 5.8|2.6|9.0|3.4|7.1
The function should return the value as 27.9 as its value...I know I need to declare and intialize the array in the main function. I don't how to write the sum function.
I'm currently trying to learn about floating point representation in depth, so I played around a bit. While doing so, I stumbled on some strange behaviour; I can't really work out what's happening...
#include <iostream> #include <cmath> using namespace std; int main(){ float minVal = pow(2,-149); // set to smallest float possible float nextCheck = ((float)((minVal/2.0f))); // divide by two
[Code] ....
Essentially what's happening is: - I set minVal to be the smallest float that can be represented using single precision - Dividing by 2 should yield 0 -- we're at the minimum - Indeed, isZero2 does return true, but isZero returns false.
What's going on -- I would have thought them to be identical? Is the compiler trying to be clever, saying that dividing any number cannot possibly yield zero?
Pointers point to an address in memory. What if I used 3 pointers: 2 to mark the first/last nodes, and the third to mark the current node being referenced? I would wrap it in a class (to make the memory management automatic, of course), but is this practical?? maybe some pseudo code will get the juices flowing:
template<class type> class supercondensed_list{ public: supercondensed_list(); ~supercondensed_list();
[code].....
Any things I should take into consideration? I'm not exactly the most experienced with pointers, and manually managing memory, but I think it's worth trying. If this works, then my programs should, in theory, be 100% memory efficient.
Using VC++ 2010 Express. I am creating a dll to export a simple Multiply function so I can use it in Excel/VBA
These e are the steps I am following :
. Create a Win32 C++ Project and give a name. For example: CallDllFromVBA . Select the DLL option in the Wizard and click Finish . In the CPP file (here CallDllFromVBA.cpp), add the following code
#include "stdafx.h" int _stdcall Multiply(int x, int y) { return x * y;
[Code] ....
The Build output show everything is ok as follows :
CallDllFromVBA.cpp CallDllFromVBA.vcxproj -> c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
In VBA, I insert a module and add the following code:
Declare Function Multiply Lib _ "c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll" _ (ByVal x As Long, ByVal y As Long) As Long Sub test() MsgBox Multiply(2, 4) End Sub
When I run the Test sub I get the error: 453 - Can't find dll entry point
I also opened the CallDllFromVBA dll with Dependency walker and I can't find the Multiply export function - In fact, the dependency walker doesn't show any function exports at all for the CallDllFromVBA dll !