[Webinar] Streamline your web hosting managementRegister Today

x
Solved

# C Function to Calculate Surface Normals

Posted on 2003-03-19
Medium Priority
1,177 Views
Hi

I'm trying to write a function in C++ to calculate a surface normal and return the normal as a 3 element array.  The function takes 9 arguments- the coords of the point at which the normal is to be calculated and the coords of two points on the vectors of the sides.  I have the maths to do this, the trouble is I can't find a neat way to return the results...  I just need a 3 element array!

Thanks!
0
Question by:mrpink123

LVL 2

Accepted Solution

TGGC earned 200 total points
ID: 8168519
a fast way

[code]
void cross( float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
float& x, float& y, float& z );
{
x= ...
y= ...
z= ...
}
[/code]

a nice way (i would prefer this!)

[code]
struct Vec3
{
float x;
float y;
float z;
}

void cross( Vec3 V1, Vec3 V2, Vec3 V3, Vec3& Result);
{
Result.x= V2.y - V1.y * V3.z -...
Result.y= ...
Result.z= ...
}
[/code]
0

LVL 4

Expert Comment

ID: 8172542

D3DXVECTOR3* myFunction()
{

D3DXVECTOR3* vecs = new D3DXVECTOR3[3];

return vecs;
}

Or ?
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
###### Suggested Courses
Course of the Month8 days, 15 hours left to enroll