PowerShell, 84 bytes
param([char]$a,$b)($b[($c=$b.length)..0],$b[0..$c])[$a%7-eq6]-join("","`n")[90-lt$a]
This is going to be complete gibberish to people not familiar with PowerShell. Let's go through it.
Takes input param([char]$a,$b)
, with an explicit cast to character for $a
. The rest of the program is one statement. We'll start with the first half, up to the -join
.
We're creating a new dynamic array (...,...)
and indexing into it with $a%7-eq6
. The ASCII values for v
and >
are 116
and 62
, respectively, and 116%7 = 62%7 = 6
, and those are the two directions that "increase" down and to the right. So, if that -eq
is $true
, we'll take the second value, which is $b[0..$c]
, or an array of the characters of $b
up to the end. We get the value $c
from the first value, $b[($c=$b.length)..0]
, which gets selected if the input char is ^
or <
(i.e., so it goes through the string backwards). Important to note is that even if the second value is selected, the $c
value is still calculated and stored, so we can re-use it as a shortcut like this.
So, we've now got an array of characters either going forwards or backwards. We then -join
those characters together with the result of another dynamic array index. This time we're selecting based on whether the ASCII value for $a
is below 90
(really lots of values would work, I selected this one just because). Since >
and <
both have a value below 90
, the -lt
is $false
, so we select the empty string ""
, and thus the char-array is simply concatenated. Otherwise, we select the newline character "`n"
to join the char-array together with newlines.
This resultant string is left on the pipeline, and output is implicit.
Example
PS C:\Tools\Scripts\golfing> .\orthogonal-orientation.ps1 "^" "TimmyD"
D
y
m
m
i
T
>ABC
\$\endgroup\$>
orientation. \$\endgroup\$