Solved

# C Function to Calculate Surface Normals

Posted on 2003-03-19
Medium Priority
1,171 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
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

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

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
###### Suggested Courses
Course of the Month15 days, 8 hours left to enroll