I got stuck trying to figure out how to orient rays so I thought I'd ask about the math here. What I want to do is use llCastRay to generate several rays all emanating from the same point but at different angles. These will be in a script attached to an avatar, so everything will be relative to the avatar's rotation. I know how to make a ray go straight out in the direction the avatar is facing:
float ray_range = 100.0;
vector ray_start = llGetPos();
vector ray_end = ray_start + <ray_range, 0.0, 0.0>*llGetRot();
list ray_results = llCastRay(ray_start, ray_end, []);
And I know how to make other rays that are parallel to but offset from the center ray:
float ray_range = 100.0;
float left_shift = 2.0; // this ray will be parallel to center ray from before but 2m left and 3m up from it
float up_shift = 3.0;
vector ray_start = llGetPos() + <0.0, left_shift, up_shift>*llGetRot();
vector ray_end = ray_start + <ray_range, 0.0, 0.0>*llGetRot();
list ray_result = llCastRay(ray_start, ray_end, []);
But I'm struggling with how to make a ray that's for example pointing 5 degrees to the right of the center ray, or pointing 2 degrees up from it. My example above is easy because the rotation is not adjusted (all rays are parallel so the rotation doesn't change) but I'm not sure how to modify that rotation with an angle offset.