RhinoCommon LightObject rotation, size and direction

Hi

How do I get the rotation (ie. amount of spin around the direction of the light) of a WorldRectangular light please?

I also need the length and width of the light source, but the LightObject.LightGeometry.Length (and Width) is a Vector3d rather than a single float. What do Length and Width actually contain please?

EDIT: What I really need is the transformation matrix of the area light (from a 1m x 1m plane).

Thanks

Paul

They are two sides of the rectangular light from the light location. Since they are vectors you can call use their property Lengh to get a scalar out of them.

So you have a location (Point3d) and two vectors. You should be able to figure out the transformation matrix from that. For Raytraced I set up the area light like this:

Fantastic, thanks Nathan.

Can you be more specific in how to do this please?

Thanks

Paul

You can use the location, width and height vectors to construct a plane with the Plane constructor Plane(Point3d, Vector3d, Vector3d).

Then figure out transform from your 1mx1m plane to it. Maybe something like Calculate rotation data between two planes could be useful.

Nathan - I have been able to get this working using your suggestion above. It is not a trivial solution, but seems to work.

I would suggest the Rhino Lights have an XForm property added (similar to InstanceObjects) so that the camera transform can be obtained in a consistent fashion with other parts of Rhino.

Thanks

Paul

FYI, there is a PlaneToPlane rotation transform helper:

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Transform_PlaneToPlane.htm

block instances are the only objects that carry an Xform of their own. There is this old request https://mcneel.myjetbrains.com/youtrack/issue/RH-20531 for that. I’ll add this thread to the item.

Thanks Nathan. It looks like the rotation transform helper is for rotations only, however a full transformation matrix (scale, rotation, translation) as is supplied with a block instance would be great.

Thanks

Paul

You only need to apply scale separately, rotation and translation are already in the transform matrix you get:

import Rhino.Geometry as RG

xform = RG.Transform.PlaneToPlane(fromPlane, toPlane)

newSubdObj = subdObj

if useScale:
    scale = RG.Transform.Scale(RG.Plane.WorldXY, scaleX, scaleY, 1.0)
    newSubdObj.Transform(xform * scale) 
else:
    newSubdObj.Transform(xform)

PlaneToPlane.gh (22.0 KB)

Fantastic, thanks Nathan, I will try this out.

Paul