#### Archived

This topic is now archived and is closed to further replies.

# EInvalidOp

This topic is 6250 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This procedure is giving me an headache. Could somebody tell me what is wrong with it?
TXPPlane = record
m_normal: TD3DXVector3;
m_distance: Single;
end;

procedure PlaneNormalize(P: TXPPlane);
var
denom: Single;
sq: Single;
begin
with P do
begin
sq := sqrt(sqr(m_normal.x) + sqr(m_normal.y) + sqr(m_normal.z));
denom := 1 / sq; // This is where the error happens.
m_normal.x := m_normal.x * denom;
m_normal.y := m_normal.y * denom;
m_normal.z := m_normal.z * denom;
m_distance := m_distance * denom;
end;
end;

Is there any other way?

##### Share on other sites
That seems like a very unusual error to call there...

Have you tried:
denom := 1 / sqrt(sqr(m_normal.x) + sqr(m_normal.y) + sqr(m_normal.z));

(just in case)

alternatively... - if you ensure that the plane normals are normalized on creation (are unitvectors) - then you can save yourself the trouble of normalizing the plane at later times. Oh wait... I think thatZ what ur trying to do...

But if you ensure that the vectors that you use to get plane normals are already unitvectors (normalized) then the resultant plane normals are already normalized after you use the crossproduct to compute them. That might be worthwhile lookin into.

Check if there is an "invert" function; and replace 1/sq with inv(sq) [might be possible] - or try writing an explicit invert function if that fails.

GOodLuCK
Henri

##### Share on other sites
What is the value of sq at crash?
(if unavailable, check the values of m_normal)

A "NAN" could perhaps trigger and EInvalidOp. You can get a NAN after a divison by zero with FPU exceptions masked, if you have a wild pointer, memory overwrites, etc. Which means that the issue is not here, it just pops up here, but damage is done elsewhere...

---
Eric Grange
http://glscene.org

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 87
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009617
• ### Who's Online (See full list)

There are no registered users currently online

×