On Saturday 26 July 2003 06:08 pm, Lewis Walker wrote:
> I think the reason that the methods are destructive to the operands is
> for performance. To be non-destructive would require the overhead of
> creating a new instance of a Vector3D for each operation to store the
> result.

Yes, that makes a lot of sense. I guess the option to do v3.add(v1,v2) is good
enough.  I guess spitting out the reference I want could be costly as well.
I've never given a lot of thought to the cost of providing a reference as a
return value.  I guess it could lead to a major abuse of memory if it were
encouraged.

> An approach worth bearing in mind for your own code - reuse the
> same instances of Classes like Vector3D etc. I do some complex vector
> algebra in one of my programs, and I pre-initialise thirty or so Vectors
> and Matrices, so that I never have to create a new instance during the
> calculations - it is MUCH faster this way!!

These are certainly approaches to keep in mind.  I had a prof who bragged
about doing things like saving all his empty objects in a resource queue.  I
suspect I will have a fair amount of redundant data I might be able to fold
together.  OTOH, I'm trying to do graphical modeling of elastic deformations,
so the more general cases may present a real challenge.

> Lewis.

Steven

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to