Core types...

I’m currently working on cleaning up and streamlining our Core types, such as the Cartesian and Matrix, but had a quick question. Should all similar types have the same functionality?

For example, I found the following functions below which do not exist on Cartesian2 but exist on Cartesian3.

flatten

cross

multiplyComponents

getMaximumComponent

getMinimumComponent

mostOrthogonalAxis

angleBetween

rotateAroundAxis

lerp

I’m pretty sure every one of these makes sense to have on Cartesian2, as well; so should I port these functions to Cartesian2? I think it’s the best choice from an API standpoint, but I wanted to see what others thought.

Thanks,

Matt

Matt,

This is OK with me. We haven’t had a need for them yet, of course, but it is good for consistency.

I’m not sure that we should include the cross product though. I’m not sure that a 2D cross product exists, unless we consider them as 3D vectors with z = 0. Then the cross product will always be +z or -z, ignoring magnitude. Perhaps the cleaner thing for client code is to be explicit and use cross for Cartesian3 in that case.

Patrick

You’re right about cross, I wasn’t thinking. I think the general guideline should be that if it makes sense to be on all of the types, it should be; but if something doesn’t exist for a given type (like cross on Cartesian2) then we just leave it off.

Agreed.