+ LY_ASSERT_SMOB (Grob, grob, 1);
+ LY_ASSERT_SMOB (Grob, refp, 2);
+ LY_ASSERT_TYPE (is_axis, axis, 3);
+
+ Axis a = Axis (scm_to_int (axis));
+
+ if (ref->common_refpoint (sc, a) != ref)
+ {
+ // ugh. should use other error message
+ SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint");
+ }
+
+ return ly_interval2scm (robust_relative_extent (sc, ref, a));
+}
+
+LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate",
+ 3, 0, 0, (SCM grob, SCM refp, SCM axis),
+ "Get the coordinate in @var{axis} direction of @var{grob} relative"
+ " to the grob @var{refp}.")
+{
+ Grob *sc = unsmob_grob (grob);
+ Grob *ref = unsmob_grob (refp);
+
+ LY_ASSERT_SMOB (Grob, grob, 1);
+ LY_ASSERT_SMOB (Grob, refp, 2);
+ LY_ASSERT_TYPE (is_axis, axis, 3);
+
+ Axis a = Axis (scm_to_int (axis));
+
+ if (ref->common_refpoint (sc, a) != ref)
+ {
+ // ugh. should use other error message
+ SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint");
+ }
+
+ return scm_from_double (sc->relative_coordinate (ref, a));