Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

TransformVectorByReference vs TransformVectorByReferenceAndOut

Started by theblair Jan 21, 2011 at 10:47 PM 0 replies 2.6k views
Original Post
theblair
theblair
Hi,

a short question about chapter 3, listing 3.1 (and the provided code for week 1 as well). What exactly is the difference between CheckPerformance::TransformVectorByReference and CheckPerformance::TransformVectorByReferenceAndOut? I know the code itself is not terribly important, but it's kinda bugging me.

Here are the snippets:


public void TransformVectorByReference()
{
Matrix rotationMatrix = Matrix.CreateRotationY(
MathHelper.ToRadians(45.0f));
// Create a vector pointing the direction the camera is facing.
Vector3 transformedReference;
Vector3.Transform(ref cameraReference, ref rotationMatrix,
out transformedReference);
// Calculate the position the camera is looking at.
Vector3.Add(ref cameraPosition, ref transformedReference,
out cameraTarget);
}


and


public void TransformVectorByReferenceAndOut()
{
Matrix rotationMatrix = Matrix.CreateRotationY(
MathHelper.ToRadians(45.0f));
// Create a vector pointing the direction the camera is facing.
Vector3 transformedReference;
Vector3.Transform(ref cameraReference, ref rotationMatrix,
out transformedReference);
// Calculate the position the camera is looking at.
Vector3.Add(ref cameraPosition, ref transformedReference,
out cameraTarget);
}


So, what am I missing?

Thanks
JWalsh
JWalsh
Hi Blair,

I, like you, do not see a difference in the code. I'm sure it was a mistake that passed by the technical editor. Often times when writing a book an author will go through multiple revisions of the code - especially if later chapters are based on earlier examples. It's not uncommon to go back and revise the code, but to forget to add it back into the chapter text, etc... In this case, he likely copied and pasted the code and forgot to make a change.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.