Skip to navigation


Maths (Geometry): AddVectors

Name: AddVectors [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Add two three-axis vectors together
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * BuildCarObjects (Part 3 of 3) calls AddVectors * GetTrackSegment (Part 3 of 3) calls AddVectors

Given a three-axis variable vectorX and a three-axis variable vectorY, this routine calculates the following addition: [ (SS T) ] vectorX = vectorY + [ (TT U) ] [ (UU V) ]
Arguments: X The offset of the vectorX variable to update: * Index * 3 of the track segment to use for the section coordinates for the inner track * &F4 = xHelmetCoord * &FA = xCoord1 * &FD = xCoord2 Y The offset of the vectorY variable to add: * Index * 3 of the track segment to use for the section coordinates for the inner track * &F4 = xHelmetCoord * &FA = xCoord1 * &FD = xCoord2 (SS T) The value to add to the first axis (TT U) The value to add to the second axis (UU V) The value to add to the third axis
.AddVectors LDA xSegmentCoordILo,Y \ Set xVectorX = xVectorY + (SS T) CLC \ ADC T \ starting with the low bytes STA xSegmentCoordILo,X LDA xSegmentCoordIHi,Y \ And then the high bytes ADC SS STA xSegmentCoordIHi,X LDA ySegmentCoordILo,Y \ Set yVectorX = yVectorY + (TT U) CLC \ ADC U \ starting with the low bytes STA ySegmentCoordILo,X LDA ySegmentCoordIHi,Y \ And then the high bytes ADC TT STA ySegmentCoordIHi,X LDA zSegmentCoordILo,Y \ Set zVectorX = zVectorY + (UU V) CLC \ ADC V \ starting with the low bytes STA zSegmentCoordILo,X LDA zSegmentCoordIHi,Y \ And then the high bytes ADC UU STA zSegmentCoordIHi,X RTS \ Return from the subroutine